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.frames;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21 import java.util.Collection;
22 import java.util.SortedSet;
23
24 import org.orekit.time.TimeScales;
25 import org.orekit.utils.IERSConventions;
26
27 /** Interface for loading Earth Orientation Parameters history.
28 * @author Luc Maisonobe
29 * @since 6.1
30 */
31 public interface EopHistoryLoader {
32
33 /** Load celestial body.
34 * @param converter converter to use for nutation corrections
35 * @param history history to fill up
36 */
37 void fillHistory(IERSConventions.NutationCorrectionConverter converter,
38 SortedSet<EOPEntry> history);
39
40 /**
41 * Interface for parsing EOP data files.
42 *
43 * @author Evan Ward
44 * @since 10.1
45 */
46 interface Parser {
47
48 /**
49 * Parse EOP from the given input stream.
50 *
51 * @param input stream to parse.
52 * @param name of the stream for error messages.
53 * @return parsed EOP entries.
54 * @throws IOException if {@code input} throws one during parsing.
55 */
56 Collection<EOPEntry> parse(InputStream input, String name) throws IOException;
57
58 /**
59 * Create a new parser for EOP data in the rapid and predicted XML format.
60 *
61 * <p>The XML EOP files are recognized thanks to their base names, which
62 * match one of the the patterns <code>finals.2000A.*.xml</code> or
63 * <code>finals.*.xml</code> where * stands for a word like "all", "daily", or
64 * "data".
65 *
66 * @param conventions used to convert between equinox-based and
67 * non-rotating-origin-based paradigms.
68 * @param itrfVersionProvider used to determine the ITRF version of parsed EOP.
69 * @param timeScales used to parse the EOP data.
70 * @return a new parser.
71 */
72 static Parser newFinalsXmlParser(
73 final IERSConventions conventions,
74 final ItrfVersionProvider itrfVersionProvider,
75 final TimeScales timeScales) {
76 return new EopXmlLoader.Parser(
77 conventions.getNutationCorrectionConverter(timeScales),
78 itrfVersionProvider,
79 timeScales.getUTC());
80 }
81
82 /**
83 * Create a new parser for EOP data in the rapid and predicted columnar format.
84 *
85 * <p>The rapid data and prediction file is recognized thanks to its base name,
86 * which match one of the the patterns <code>finals.*</code> or
87 * <code>finals2000A.*</code> where * stands for a word like "all", "daily", or
88 * "data". The file with 2000A in their name correspond to the IAU-2000
89 * precession-nutation model whereas the files without any identifier correspond
90 * to the IAU-1980 precession-nutation model. The files with the all suffix start
91 * from 1973-01-01, and the files with the data suffix start from 1992-01-01.
92 *
93 * @param conventions used to convert between equinox-based and
94 * non-rotating-origin-based paradigms.
95 * @param itrfVersionProvider used to determine the ITRF version of parsed EOP.
96 * @param timeScales used to parse the EOP data.
97 * @param isNonRotatingOrigin if true the supported files <em>must</em> contain
98 * δX/δY nutation corrections, otherwise they
99 * <em>must</em> contain δΔψ/δΔε nutation
100 * corrections
101 * @return a new parser.
102 */
103 static Parser newFinalsColumnsParser(
104 final IERSConventions conventions,
105 final ItrfVersionProvider itrfVersionProvider,
106 final TimeScales timeScales,
107 final boolean isNonRotatingOrigin) {
108 return new RapidDataAndPredictionColumnsLoader.Parser(
109 conventions.getNutationCorrectionConverter(timeScales),
110 itrfVersionProvider,
111 timeScales.getUTC(),
112 isNonRotatingOrigin);
113 }
114
115 /**
116 * Create a new parser for EOP data in the EOP C04 format.
117 *
118 * <p>The EOP xx C04 files are recognized thanks to their base names, which
119 * match one of the patterns {@code eopc04_##_IAU2000.##} or {@code eopc04_##.##}
120 * where # stands for a digit character.
121 *
122 * @param conventions used to convert between equinox-based and
123 * non-rotating-origin-based paradigms.
124 * @param itrfVersionProvider used to determine the ITRF version of parsed EOP.
125 * @param timeScales used to parse the EOP data.
126 * @return a new parser.
127 */
128 static Parser newEopC04Parser(
129 final IERSConventions conventions,
130 final ItrfVersionProvider itrfVersionProvider,
131 final TimeScales timeScales) {
132 return new EopC04FilesLoader.Parser(conventions.getNutationCorrectionConverter(timeScales),
133 timeScales.getUTC());
134 }
135
136 /**
137 * Create a new parser for EOP data in the Bulletin B format.
138 *
139 * @param conventions used to convert between equinox-based and
140 * non-rotating-origin-based paradigms.
141 * @param itrfVersionProvider used to determine the ITRF version of parsed EOP.
142 * @param timeScales used to parse the EOP data.
143 * @return a new parser.
144 */
145 static Parser newBulletinBParser(
146 final IERSConventions conventions,
147 final ItrfVersionProvider itrfVersionProvider,
148 final TimeScales timeScales) {
149 return new BulletinBFilesLoader.Parser(
150 conventions.getNutationCorrectionConverter(timeScales),
151 itrfVersionProvider,
152 timeScales.getUTC());
153 }
154
155
156 }
157
158 }