1 /* Copyright 2002-2025 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.time;
18
19 import java.io.Serializable;
20
21 import org.orekit.annotation.DefaultDataContext;
22 import org.orekit.data.DataContext;
23 import org.orekit.frames.EOPHistory;
24 import org.orekit.frames.LazyLoadedEop;
25 import org.orekit.utils.IERSConventions;
26
27
28 /** Factory for predefined time scales.
29 * <p>
30 * This is a utility class, so its constructor is private.
31 * </p>
32 * @author Luc Maisonobe
33 * @see TimeScales
34 * @see LazyLoadedTimeScales
35 */
36 public class TimeScalesFactory implements Serializable {
37
38 /** Serializable UID. */
39 private static final long serialVersionUID = 20190927L;
40
41 /** Private constructor.
42 * <p>This class is a utility class, it should neither have a public
43 * nor a default constructor. This private constructor prevents
44 * the compiler from generating one automatically.</p>
45 */
46 private TimeScalesFactory() {
47 }
48
49 /**
50 * Get the instance of {@link TimeScales} that is called by all of the static methods
51 * in this class.
52 *
53 * @return the time scales used by this factory.
54 */
55 @DefaultDataContext
56 public static LazyLoadedTimeScales getTimeScales() {
57 return DataContext.getDefault().getTimeScales();
58 }
59
60 /** Add a loader for UTC-TAI offsets history files.
61 * @param loader custom loader to add
62 * @see TAIUTCDatFilesLoader
63 * @see UTCTAIHistoryFilesLoader
64 * @see UTCTAIBulletinAFilesLoader
65 * @see #getUTC()
66 * @see #clearUTCTAIOffsetsLoaders()
67 * @since 7.1
68 */
69 @DefaultDataContext
70 public static void addUTCTAIOffsetsLoader(final UTCTAIOffsetsLoader loader) {
71 getTimeScales().addUTCTAIOffsetsLoader(loader);
72 }
73
74 /** Add the default loaders for UTC-TAI offsets history files (both IERS and USNO).
75 * <p>
76 * The default loaders are {@link TAIUTCDatFilesLoader} that looks for
77 * a file named {@code tai-utc.dat} that must be in USNO format and
78 * {@link UTCTAIHistoryFilesLoader} that looks fir a file named
79 * {@code UTC-TAI.history} that must be in the IERS format. The
80 * {@link UTCTAIBulletinAFilesLoader} is <em>not</em> added by default
81 * as it is not recommended. USNO warned us that the TAI-UTC data present
82 * in bulletin A was for convenience only and was not reliable, there
83 * have been errors in several bulletins regarding these data.
84 * </p>
85 * @see <a href="http://maia.usno.navy.mil/ser7/tai-utc.dat">USNO tai-utc.dat file</a>
86 * @see <a href="http://hpiers.obspm.fr/eoppc/bul/bulc/UTC-TAI.history">IERS UTC-TAI.history file</a>
87 * @see TAIUTCDatFilesLoader
88 * @see UTCTAIHistoryFilesLoader
89 * @see #getUTC()
90 * @see #clearUTCTAIOffsetsLoaders()
91 * @since 7.1
92 */
93 @DefaultDataContext
94 public static void addDefaultUTCTAIOffsetsLoaders() {
95 getTimeScales().addDefaultUTCTAIOffsetsLoaders();
96 }
97
98 /** Clear loaders for UTC-TAI offsets history files.
99 * @see #getUTC()
100 * @see #addUTCTAIOffsetsLoader(UTCTAIOffsetsLoader)
101 * @see #addDefaultUTCTAIOffsetsLoaders()
102 * @since 7.1
103 */
104 @DefaultDataContext
105 public static void clearUTCTAIOffsetsLoaders() {
106 getTimeScales().clearUTCTAIOffsetsLoaders();
107 }
108
109 /** Get the International Atomic Time scale.
110 * @return International Atomic Time scale
111 */
112 @DefaultDataContext
113 public static TAIScale getTAI() {
114 return getTimeScales().getTAI();
115 }
116
117 /** Get the Universal Time Coordinate scale.
118 * <p>
119 * If no {@link UTCTAIOffsetsLoader} has been added by calling {@link
120 * #addUTCTAIOffsetsLoader(UTCTAIOffsetsLoader) addUTCTAIOffsetsLoader} or if {@link
121 * #clearUTCTAIOffsetsLoaders() clearUTCTAIOffsetsLoaders} has been called afterwards,
122 * the {@link #addDefaultUTCTAIOffsetsLoaders() addDefaultUTCTAILoaders} method
123 * will be called automatically.
124 * </p>
125 * @return Universal Time Coordinate scale
126 * @see #addDefaultUTCTAIOffsetsLoaders()
127 */
128 @DefaultDataContext
129 public static UTCScale getUTC() {
130 return getTimeScales().getUTC();
131 }
132
133 /** Get the Universal Time 1 scale.
134 * <p>
135 * UT1 scale depends on both UTC scale and Earth Orientation Parameters,
136 * so this method loads these data sets. See the {@link #getUTC()
137 * TimeScalesFactory.getUTC()} and {@link
138 * LazyLoadedEop#getEOPHistory(IERSConventions, boolean, TimeScales)} methods
139 * for an explanation of how the corresponding data loaders can be configured.
140 * </p>
141 * @param conventions IERS conventions for which EOP parameters will provide dUT1
142 * @param simpleEOP if true, tidal effects are ignored when interpolating EOP
143 * @return Universal Time 1 scale
144 * @see #getUTC()
145 * @see LazyLoadedEop#getEOPHistory(IERSConventions, boolean, TimeScales)
146 */
147 @DefaultDataContext
148 public static UT1Scale getUT1(final IERSConventions conventions, final boolean simpleEOP) {
149 return getTimeScales().getUT1(conventions, simpleEOP);
150 }
151
152 /** Get the Universal Time 1 scale.
153 * <p>
154 * As this method allow associating any history with the time scale,
155 * it may involve large data sets. So this method does <em>not</em>
156 * cache the resulting {@link UT1Scale UT1Scale} instance, a new
157 * instance will be returned each time. In order to avoid wasting
158 * memory, calling {@link #getUT1(IERSConventions, boolean)}
159 * with the single enumerate corresponding to the conventions may be
160 * a better solution. This method is made available only for expert use.
161 * </p>
162 * @param history EOP parameters providing dUT1
163 * (may be null if no correction is desired)
164 * @return Universal Time 1 scale
165 * @see #getUT1(IERSConventions, boolean)
166 */
167 @DefaultDataContext
168 public static UT1Scale getUT1(final EOPHistory history) {
169 return getTimeScales().getUT1(history);
170 }
171
172 /** Get the Terrestrial Time scale.
173 * @return Terrestrial Time scale
174 */
175 @DefaultDataContext
176 public static TTScale getTT() {
177 return getTimeScales().getTT();
178 }
179
180 /** Get the Galileo System Time scale.
181 * @return Galileo System Time scale
182 */
183 @DefaultDataContext
184 public static GalileoScale getGST() {
185 return getTimeScales().getGST();
186 }
187
188 /** Get the GLObal NAvigation Satellite System time scale.
189 * @return GLObal NAvigation Satellite System time scale
190 */
191 @DefaultDataContext
192 public static GLONASSScale getGLONASS() {
193 return getTimeScales().getGLONASS();
194 }
195
196 /** Get the Quasi-Zenith Satellite System time scale.
197 * @return Quasi-Zenith Satellite System time scale
198 */
199 @DefaultDataContext
200 public static QZSSScale getQZSS() {
201 return getTimeScales().getQZSS();
202 }
203
204 /** Get the Global Positioning System scale.
205 * @return Global Positioning System scale
206 */
207 @DefaultDataContext
208 public static GPSScale getGPS() {
209 return getTimeScales().getGPS();
210 }
211
212 /** Get the Geocentric Coordinate Time scale.
213 * @return Geocentric Coordinate Time scale
214 */
215 @DefaultDataContext
216 public static TCGScale getTCG() {
217 return getTimeScales().getTCG();
218 }
219
220 /** Get the Barycentric Dynamic Time scale.
221 * @return Barycentric Dynamic Time scale
222 */
223 @DefaultDataContext
224 public static TDBScale getTDB() {
225 return getTimeScales().getTDB();
226 }
227
228 /** Get the Barycentric Coordinate Time scale.
229 * @return Barycentric Coordinate Time scale
230 */
231 @DefaultDataContext
232 public static TCBScale getTCB() {
233 return getTimeScales().getTCB();
234 }
235
236 /** Get the Greenwich Mean Sidereal Time scale.
237 * @param conventions IERS conventions for which EOP parameters will provide dUT1
238 * @param simpleEOP if true, tidal effects are ignored when interpolating EOP
239 * @return Greenwich Mean Sidereal Time scale
240 * @since 7.0
241 */
242 @DefaultDataContext
243 public static GMSTScale getGMST(final IERSConventions conventions, final boolean simpleEOP) {
244 return getTimeScales().getGMST(conventions, simpleEOP);
245 }
246
247 /** Get the Navigation with Indian Constellation time scale.
248 * @return Navigation with Indian Constellation time scale
249 */
250 @DefaultDataContext
251 public static NavicScale getNavIC() {
252 return getTimeScales().getNavIC();
253 }
254
255 /** Get the BeiDou Navigation Satellite System time scale.
256 * @return BeiDou Navigation Satellite System time scale
257 */
258 @DefaultDataContext
259 public static BDTScale getBDT() {
260 return getTimeScales().getBDT();
261 }
262
263
264 }