1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.time;
18
19 import java.util.concurrent.ConcurrentHashMap;
20 import java.util.concurrent.ConcurrentMap;
21
22 import org.hipparchus.util.MathArrays;
23 import org.hipparchus.util.Pair;
24 import org.orekit.frames.EOPHistory;
25 import org.orekit.utils.Constants;
26 import org.orekit.utils.IERSConventions;
27
28
29
30
31
32
33
34
35 public abstract class AbstractTimeScales implements TimeScales {
36
37
38 private final ConcurrentMap<Pair<IERSConventions, Boolean>, GMSTScale> gmstMap;
39
40 private final ConcurrentMap<Pair<IERSConventions, Boolean>, UT1Scale> ut1Map;
41
42
43 public AbstractTimeScales() {
44 final int n = IERSConventions.values().length;
45 gmstMap = new ConcurrentHashMap<>(n * 2);
46 ut1Map = new ConcurrentHashMap<>(n * 2);
47 }
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 protected UT1Scale getUT1(final EOPHistory history) {
66 return new UT1Scale(history, getUTC());
67 }
68
69
70
71
72
73
74
75
76 protected abstract EOPHistory getEopHistory(IERSConventions conventions,
77 boolean simpleEOP);
78
79 @Override
80 public UT1Scale getUT1(final IERSConventions conventions, final boolean simpleEOP) {
81 return ut1Map.computeIfAbsent(
82 new Pair<>(conventions, simpleEOP),
83 k -> getUT1(getEopHistory(conventions, simpleEOP)));
84 }
85
86 @Override
87 public GMSTScale getGMST(final IERSConventions conventions, final boolean simpleEOP) {
88 return gmstMap.computeIfAbsent(
89 new Pair<>(conventions, simpleEOP),
90 k -> new GMSTScale(getUT1(conventions, simpleEOP)));
91 }
92
93 @Override
94 public AbsoluteDate getJulianEpoch() {
95 return new AbsoluteDate(DateComponents.JULIAN_EPOCH, TimeComponents.H12, this.getTT());
96 }
97
98 @Override
99 public AbsoluteDate getModifiedJulianEpoch() {
100 return new AbsoluteDate(DateComponents.MODIFIED_JULIAN_EPOCH, TimeComponents.H00, this.getTT());
101 }
102
103 @Override
104 public AbsoluteDate getFiftiesEpoch() {
105 return new AbsoluteDate(DateComponents.FIFTIES_EPOCH, TimeComponents.H00, this.getTT());
106 }
107
108 @Override
109 public AbsoluteDate getCcsdsEpoch() {
110 return new AbsoluteDate(DateComponents.CCSDS_EPOCH, TimeComponents.H00, this.getTAI());
111 }
112
113 @Override
114 public AbsoluteDate getGalileoEpoch() {
115 return new AbsoluteDate(DateComponents.GALILEO_EPOCH, TimeComponents.H00, this.getGST());
116 }
117
118 @Override
119 public AbsoluteDate getGpsEpoch() {
120 return new AbsoluteDate(DateComponents.GPS_EPOCH, TimeComponents.H00, this.getGPS());
121 }
122
123 @Override
124 public AbsoluteDate getQzssEpoch() {
125 return new AbsoluteDate(DateComponents.QZSS_EPOCH, TimeComponents.H00, this.getQZSS());
126 }
127
128 @Override
129 public AbsoluteDate getIrnssEpoch() {
130 return new AbsoluteDate(DateComponents.IRNSS_EPOCH, TimeComponents.H00, this.getIRNSS());
131 }
132
133 @Override
134 public AbsoluteDate getBeidouEpoch() {
135 return new AbsoluteDate(DateComponents.BEIDOU_EPOCH, TimeComponents.H00, this.getBDT());
136 }
137
138 @Override
139 public AbsoluteDate getGlonassEpoch() {
140 return new AbsoluteDate(DateComponents.GLONASS_EPOCH,
141 new TimeComponents(29.0), this.getTAI()).shiftedBy(-10800.0);
142 }
143
144 @Override
145 public AbsoluteDate getJ2000Epoch() {
146 return new AbsoluteDate(DateComponents.J2000_EPOCH, TimeComponents.H12, this.getTT());
147 }
148
149 @Override
150 public AbsoluteDate getJavaEpoch() {
151 return new AbsoluteDate(DateComponents.JAVA_EPOCH, this.getTAI()).shiftedBy(8.000082);
152 }
153
154 @Override
155 public AbsoluteDate getPastInfinity() {
156 return getJavaEpoch().shiftedBy(Double.NEGATIVE_INFINITY);
157 }
158
159 @Override
160 public AbsoluteDate getFutureInfinity() {
161 return getJavaEpoch().shiftedBy(Double.POSITIVE_INFINITY);
162 }
163
164 @Override
165 public AbsoluteDate createJulianEpoch(final double julianEpoch) {
166 return new AbsoluteDate(getJ2000Epoch(),
167 Constants.JULIAN_YEAR * (julianEpoch - 2000.0));
168 }
169
170 @Override
171 public AbsoluteDate createBesselianEpoch(final double besselianEpoch) {
172 return new AbsoluteDate(getJ2000Epoch(),
173 MathArrays.linearCombination(
174 Constants.BESSELIAN_YEAR, besselianEpoch - 1900,
175 Constants.JULIAN_DAY, -36525,
176 Constants.JULIAN_DAY, 0.31352));
177 }
178
179 }