...
 
Commits (11)
......@@ -25,7 +25,7 @@ package org.orekit.data;
class DefaultDataContextHolder {
/** The default Orekit data context. */
private static LazyLoadedDataContext INSTANCE = new LazyLoadedDataContext();
private static volatile LazyLoadedDataContext INSTANCE = new LazyLoadedDataContext();
/** Private Constructor. */
private DefaultDataContextHolder() {
......
......@@ -184,7 +184,8 @@ public class GroundStation {
throw new OrekitException(OrekitMessages.NO_EARTH_ORIENTATION_PARAMETERS);
}
final UT1Scale baseUT1 = eopHistory.getTimeScales().getUT1(eopHistory);
final UT1Scale baseUT1 = eopHistory.getTimeScales()
.getUT1(eopHistory.getConventions(), eopHistory.isSimpleEop());
this.estimatedEarthFrameProvider = new EstimatedEarthFrameProvider(baseUT1);
this.estimatedEarthFrame = new Frame(baseFrame.getParent(), estimatedEarthFrameProvider,
baseFrame.getParent() + "-estimated");
......
package org.orekit.frames;
import org.orekit.frames.EOPHistoryLoader.Parser;
import org.orekit.time.TimeScale;
import org.orekit.utils.IERSConventions;
import org.orekit.utils.IERSConventions.NutationCorrectionConverter;
/**
* Abstract class that holds common data used by several implementations of {@link
* Parser}.
*
* @author Evan Ward
* @since 10.1
*/
abstract class AbstractEopParser implements Parser {
/** Converter for nutation corrections. */
private final IERSConventions.NutationCorrectionConverter converter;
/** Configuration for ITRF versions. */
private final ItrfVersionProvider itrfVersionProvider;
/** UTC time scale. */
private final TimeScale utc;
/**
* Simple constructor.
*
* @param converter converter to use
* @param itrfVersionProvider to use for determining the ITRF version of the EOP.
* @param utc time scale for parsing dates.
*/
protected AbstractEopParser(final NutationCorrectionConverter converter,
final ItrfVersionProvider itrfVersionProvider,
final TimeScale utc) {
this.converter = converter;
this.itrfVersionProvider = itrfVersionProvider;
this.utc = utc;
}
/**
* Get the nutation converter.
*
* @return the nutation converter.
*/
protected NutationCorrectionConverter getConverter() {
return converter;
}
/**
* Get the ITRF version loader.
*
* @return ITRF version loader.
*/
protected ItrfVersionProvider getItrfVersionProvider() {
return itrfVersionProvider;
}
/**
* Get the UTC time scale.
*
* @return UTC time scale.
*/
protected TimeScale getUtc() {
return utc;
}
}
This diff is collapsed.
......@@ -378,7 +378,7 @@ class BulletinAFilesLoader extends AbstractEopLoader implements EOPHistoryLoader
private final Map<Integer, double[]> poleOffsetsFieldsMap;
/** Configuration for ITRF versions. */
private final ITRFVersionLoader itrfVersionLoader;
private final ItrfVersionProvider itrfVersionProvider;
/** ITRF version configuration. */
private ITRFVersionLoader.ITRFVersionConfiguration configuration;
......@@ -406,7 +406,7 @@ class BulletinAFilesLoader extends AbstractEopLoader implements EOPHistoryLoader
Parser() {
this.eopFieldsMap = new HashMap<>();
this.poleOffsetsFieldsMap = new HashMap<>();
this.itrfVersionLoader = new ITRFVersionLoader(
this.itrfVersionProvider = new ITRFVersionLoader(
ITRFVersionLoader.SUPPORTED_NAMES,
getDataProvidersManager());
this.lineNumber = 0;
......@@ -495,7 +495,7 @@ class BulletinAFilesLoader extends AbstractEopLoader implements EOPHistoryLoader
// we have only pole offsets for this date
if (configuration == null || !configuration.isValid(mjd)) {
// get a configuration for current name and date range
configuration = itrfVersionLoader.getConfiguration(fileName, mjd);
configuration = itrfVersionProvider.getConfiguration(fileName, mjd);
}
history.add(new EOPEntry(mjd,
0.0, 0.0, 0.0, 0.0,
......@@ -530,7 +530,7 @@ class BulletinAFilesLoader extends AbstractEopLoader implements EOPHistoryLoader
if (configuration == null || !configuration.isValid(mjd)) {
// get a configuration for current name and date range
configuration = itrfVersionLoader.getConfiguration(fileName, mjd);
configuration = itrfVersionProvider.getConfiguration(fileName, mjd);
}
if (currentPole == null) {
// we have only EOP for this date
......
......@@ -22,6 +22,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -30,7 +31,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.hipparchus.util.FastMath;
import org.orekit.data.DataLoader;
import org.orekit.data.DataProvidersManager;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
......@@ -40,6 +40,7 @@ import org.orekit.time.Month;
import org.orekit.time.TimeScale;
import org.orekit.utils.Constants;
import org.orekit.utils.IERSConventions;
import org.orekit.utils.IERSConventions.NutationCorrectionConverter;
/** Loader for bulletin B files.
* <p>Bulletin B files contain {@link EOPEntry
......@@ -235,25 +236,23 @@ class BulletinBFilesLoader extends AbstractEopLoader implements EOPHistoryLoader
/** {@inheritDoc} */
public void fillHistory(final IERSConventions.NutationCorrectionConverter converter,
final SortedSet<EOPEntry> history) {
final Parser parser = new Parser(converter);
this.feed(parser);
history.addAll(parser.history);
final ItrfVersionProvider itrfVersionProvider = new ITRFVersionLoader(
ITRFVersionLoader.SUPPORTED_NAMES,
getDataProvidersManager());
final Parser parser = new Parser(converter, itrfVersionProvider, getUtc());
final EopParserLoader loader = new EopParserLoader(parser);
this.feed(loader);
history.addAll(loader.getEop());
}
/** Internal class performing the parsing. */
private class Parser implements DataLoader {
/** Converter for nutation corrections. */
private final IERSConventions.NutationCorrectionConverter converter;
/** Configuration for ITRF versions. */
private final ITRFVersionLoader itrfVersionLoader;
static class Parser extends AbstractEopParser {
/** ITRF version configuration. */
private ITRFVersionLoader.ITRFVersionConfiguration configuration;
/** History entries. */
private final List<EOPEntry> history;
private List<EOPEntry> history;
/** Map for fields read in different sections. */
private final Map<Integer, double[]> fieldsMap;
......@@ -270,15 +269,17 @@ class BulletinBFilesLoader extends AbstractEopLoader implements EOPHistoryLoader
/** End of final data. */
private int mjdMax;
/** Simple constructor.
* @param converter converter to use
/**
* Simple constructor.
*
* @param converter converter to use
* @param itrfVersionProvider to use for determining the ITRF version of the EOP.
* @param utc time scale for parsing dates.
*/
Parser(final IERSConventions.NutationCorrectionConverter converter) {
this.converter = converter;
this.itrfVersionLoader = new ITRFVersionLoader(
ITRFVersionLoader.SUPPORTED_NAMES,
getDataProvidersManager());
this.history = new ArrayList<>();
Parser(final NutationCorrectionConverter converter,
final ItrfVersionProvider itrfVersionProvider,
final TimeScale utc) {
super(converter, itrfVersionProvider, utc);
this.fieldsMap = new HashMap<>();
this.lineNumber = 0;
this.mjdMin = Integer.MAX_VALUE;
......@@ -286,24 +287,20 @@ class BulletinBFilesLoader extends AbstractEopLoader implements EOPHistoryLoader
}
/** {@inheritDoc} */
public boolean stillAcceptsData() {
return true;
}
/** {@inheritDoc} */
public void loadData(final InputStream input, final String name)
@Override
public Collection<EOPEntry> parse(final InputStream input, final String name)
throws IOException {
configuration = null;
// set up a reader for line-oriented bulletin B files
final BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
// reset parse info to start new file (do not clear history!)
// reset parse info to start new file
fieldsMap.clear();
lineNumber = 0;
mjdMin = Integer.MAX_VALUE;
mjdMax = Integer.MIN_VALUE;
history = new ArrayList<>();
configuration = null;
// skip header up to section 1 and check if we are parsing an old or new format file
final Matcher section1Matcher = seekToLine(SECTION_1_HEADER, reader, name);
......@@ -339,10 +336,10 @@ class BulletinBFilesLoader extends AbstractEopLoader implements EOPHistoryLoader
final AbsoluteDate mjdDate =
new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, mjd),
getUtc());
final double[] equinox = converter.toEquinox(mjdDate, array[4], array[5]);
final double[] equinox = getConverter().toEquinox(mjdDate, array[4], array[5]);
if (configuration == null || !configuration.isValid(mjd)) {
// get a configuration for current name and date range
configuration = itrfVersionLoader.getConfiguration(name, mjd);
configuration = getItrfVersionProvider().getConfiguration(name, mjd);
}
history.add(new EOPEntry(mjd, array[0], array[1], array[2], array[3],
equinox[0], equinox[1], array[4], array[5],
......@@ -351,6 +348,8 @@ class BulletinBFilesLoader extends AbstractEopLoader implements EOPHistoryLoader
}
return history;
}
/** Read until a line matching a pattern is found.
......@@ -447,17 +446,17 @@ class BulletinBFilesLoader extends AbstractEopLoader implements EOPHistoryLoader
Double.parseDouble(matcher.group(6)) * MILLI_ARC_SECONDS_TO_RADIANS,
Double.parseDouble(matcher.group(7)) * MILLI_ARC_SECONDS_TO_RADIANS
};
equinox = converter.toEquinox(mjdDate, nro[0], nro[1]);
equinox = getConverter().toEquinox(mjdDate, nro[0], nro[1]);
} else {
equinox = new double[] {
Double.parseDouble(matcher.group(6)) * MILLI_ARC_SECONDS_TO_RADIANS,
Double.parseDouble(matcher.group(7)) * MILLI_ARC_SECONDS_TO_RADIANS
};
nro = converter.toNonRotating(mjdDate, equinox[0], equinox[1]);
nro = getConverter().toNonRotating(mjdDate, equinox[0], equinox[1]);
}
if (configuration == null || !configuration.isValid(mjd)) {
// get a configuration for current name and date range
configuration = itrfVersionLoader.getConfiguration(name, mjd);
configuration = getItrfVersionProvider().getConfiguration(name, mjd);
}
history.add(new EOPEntry(mjd, dtu1, lod, x, y, equinox[0], equinox[1], nro[0], nro[1],
configuration.getVersion(), mjdDate));
......
......@@ -22,12 +22,12 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.SortedSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.orekit.data.DataLoader;
import org.orekit.data.DataProvidersManager;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
......@@ -36,6 +36,7 @@ import org.orekit.time.DateComponents;
import org.orekit.time.TimeScale;
import org.orekit.utils.Constants;
import org.orekit.utils.IERSConventions;
import org.orekit.utils.IERSConventions.NutationCorrectionConverter;
/** Loader for EOP xx C04 files.
* <p>EOP xx C04 files contain {@link EOPEntry
......@@ -155,43 +156,36 @@ class EOPC04FilesLoader extends AbstractEopLoader implements EOPHistoryLoader {
/** {@inheritDoc} */
public void fillHistory(final IERSConventions.NutationCorrectionConverter converter,
final SortedSet<EOPEntry> history) {
final Parser parser = new Parser(converter);
this.feed(parser);
history.addAll(parser.history);
final ItrfVersionProvider itrfVersionProvider = new ITRFVersionLoader(
ITRFVersionLoader.SUPPORTED_NAMES,
getDataProvidersManager());
final Parser parser = new Parser(converter, itrfVersionProvider, getUtc());
final EopParserLoader loader = new EopParserLoader(parser);
this.feed(loader);
history.addAll(loader.getEop());
}
/** Internal class performing the parsing. */
private class Parser implements DataLoader {
/** Converter for nutation corrections. */
private final IERSConventions.NutationCorrectionConverter converter;
/** Configuration for ITRF versions. */
private final ITRFVersionLoader itrfVersionLoader;
/** History entries. */
private final List<EOPEntry> history;
/** Simple constructor.
* @param converter converter to use
static class Parser extends AbstractEopParser {
/**
* Simple constructor.
*
* @param converter converter to use
* @param itrfVersionProvider to use for determining the ITRF version of the EOP.
* @param utc time scale for parsing dates.
*/
Parser(final IERSConventions.NutationCorrectionConverter converter) {
this.converter = converter;
this.itrfVersionLoader = new ITRFVersionLoader(
ITRFVersionLoader.SUPPORTED_NAMES,
getDataProvidersManager());
this.history = new ArrayList<>();
}
/** {@inheritDoc} */
public boolean stillAcceptsData() {
return true;
Parser(final NutationCorrectionConverter converter,
final ItrfVersionProvider itrfVersionProvider,
final TimeScale utc) {
super(converter, itrfVersionProvider, utc);
}
/** {@inheritDoc} */
public void loadData(final InputStream input, final String name)
public Collection<EOPEntry> parse(final InputStream input, final String name)
throws IOException, OrekitException {
final List<EOPEntry> history = new ArrayList<>();
ITRFVersionLoader.ITRFVersionConfiguration configuration = null;
// set up a reader for line-oriented bulletin B files
......@@ -242,17 +236,17 @@ class EOPC04FilesLoader extends AbstractEopLoader implements EOPHistoryLoader {
Double.parseDouble(fields[NUT_0_FIELD]) * Constants.ARC_SECONDS_TO_RADIANS,
Double.parseDouble(fields[NUT_1_FIELD]) * Constants.ARC_SECONDS_TO_RADIANS
};
equinox = converter.toEquinox(date, nro[0], nro[1]);
equinox = getConverter().toEquinox(date, nro[0], nro[1]);
} else {
equinox = new double[] {
Double.parseDouble(fields[NUT_0_FIELD]) * Constants.ARC_SECONDS_TO_RADIANS,
Double.parseDouble(fields[NUT_1_FIELD]) * Constants.ARC_SECONDS_TO_RADIANS
};
nro = converter.toNonRotating(date, equinox[0], equinox[1]);
nro = getConverter().toNonRotating(date, equinox[0], equinox[1]);
}
if (configuration == null || !configuration.isValid(mjd)) {
// get a configuration for current name and date range
configuration = itrfVersionLoader.getConfiguration(name, mjd);
configuration = getItrfVersionProvider().getConfiguration(name, mjd);
}
history.add(new EOPEntry(mjd, dtu1, lod, x, y, equinox[0], equinox[1], nro[0], nro[1],
configuration.getVersion(), date));
......@@ -270,6 +264,7 @@ class EOPC04FilesLoader extends AbstractEopLoader implements EOPHistoryLoader {
throw new OrekitException(OrekitMessages.NOT_A_SUPPORTED_IERS_DATA_FILE, name);
}
return history;
}
}
......
......@@ -88,7 +88,7 @@ public class EOPHistory implements Serializable {
* @see #EOPHistory(IERSConventions, Collection, boolean, TimeScales)
*/
protected EOPHistory(final IERSConventions conventions,
final Collection<EOPEntry> data,
final Collection<? extends EOPEntry> data,
final boolean simpleEOP) {
this(conventions, data, simpleEOP, DataContext.getDefault().getTimeScales());
}
......@@ -100,10 +100,10 @@ public class EOPHistory implements Serializable {
* @param timeScales to use when computing EOP corrections.
* @since 10.1
*/
protected EOPHistory(final IERSConventions conventions,
final Collection<EOPEntry> data,
final boolean simpleEOP,
final TimeScales timeScales) {
public EOPHistory(final IERSConventions conventions,
final Collection<? extends EOPEntry> data,
final boolean simpleEOP,
final TimeScales timeScales) {
this(conventions,
data,
simpleEOP ? null : new CachedCorrection(conventions.getEOPTidalCorrection(timeScales)),
......@@ -118,7 +118,7 @@ public class EOPHistory implements Serializable {
* @since 10.1
*/
private EOPHistory(final IERSConventions conventions,
final Collection<EOPEntry> data,
final Collection<? extends EOPEntry> data,
final TimeVectorFunction tidalCorrection,
final TimeScales timeScales) {
this.conventions = conventions;
......@@ -135,6 +135,15 @@ public class EOPHistory implements Serializable {
}
}
/**
* Determine if this history uses simplified EOP corrections.
*
* @return {@code true} if tidal corrections are ignored, {@code false} otherwise.
*/
public boolean isSimpleEop() {
return tidalCorrection == null;
}
/**
* Get the time scales used in computing EOP corrections.
*
......
......@@ -16,8 +16,12 @@
*/
package org.orekit.frames;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.SortedSet;
import org.orekit.time.TimeScales;
import org.orekit.utils.IERSConventions;
/** Interface for loading Earth Orientation Parameters history.
......@@ -33,4 +37,124 @@ public interface EOPHistoryLoader {
void fillHistory(IERSConventions.NutationCorrectionConverter converter,
SortedSet<EOPEntry> history);
/**
* Interface for parsing EOP data files.
*
* @author Evan Ward
* @since 10.1
*/
interface Parser {
/**
* Parse EOP from the given input stream.
*
* @param input stream to parse.
* @param name of the stream for error messages.
* @return parsed EOP entries.
* @throws IOException if {@code input} throws one during parsing.
*/
Collection<EOPEntry> parse(InputStream input, String name) throws IOException;
/**
* Create a new parser for EOP data in the rapid and predicted XML format.
*
* <p>The XML EOP files are recognized thanks to their base names, which
* match one of the the patterns <code>finals.2000A.*.xml</code> or
* <code>finals.*.xml</code> where * stands for a word like "all", "daily", or
* "data".
*
* @param conventions used to convert between equinox-based and
* non-rotating-origin-based paradigms.
* @param itrfVersionProvider used to determine the ITRF version of parsed EOP.
* @param timeScales used to parse the EOP data.
* @return a new parser.
*/
static Parser newFinalsXmlParser(
final IERSConventions conventions,
final ItrfVersionProvider itrfVersionProvider,
final TimeScales timeScales) {
return new RapidDataAndPredictionXMLLoader.Parser(
conventions.getNutationCorrectionConverter(timeScales),
itrfVersionProvider,
timeScales.getUTC());
}
/**
* Create a new parser for EOP data in the rapid and predicted columnar format.
*
* <p>The rapid data and prediction file is recognized thanks to its base name,
* which match one of the the patterns <code>finals.*</code> or
* <code>finals2000A.*</code> where * stands for a word like "all", "daily", or
* "data". The file with 2000A in their name correspond to the IAU-2000
* precession-nutation model whereas the files without any identifier correspond
* to the IAU-1980 precession-nutation model. The files with the all suffix start
* from 1973-01-01, and the files with the data suffix start from 1992-01-01.
*
* @param conventions used to convert between equinox-based and
* non-rotating-origin-based paradigms.
* @param itrfVersionProvider used to determine the ITRF version of parsed EOP.
* @param timeScales used to parse the EOP data.
* @param isNonRotatingOrigin if true the supported files <em>must</em> contain
* δX/δY nutation corrections, otherwise they
* <em>must</em> contain δΔψ/δΔε nutation
* corrections
* @return a new parser.
*/
static Parser newFinalsColumnsParser(
final IERSConventions conventions,
final ItrfVersionProvider itrfVersionProvider,
final TimeScales timeScales,
final boolean isNonRotatingOrigin) {
return new RapidDataAndPredictionColumnsLoader.Parser(
conventions.getNutationCorrectionConverter(timeScales),
itrfVersionProvider,
timeScales.getUTC(),
isNonRotatingOrigin);
}
/**
* Create a new parser for EOP data in the EOP C04 format.
*
* <p>The EOP xx C04 files are recognized thanks to their base names, which
* match one of the patterns {@code eopc04_##_IAU2000.##} or {@code eopc04_##.##}
* where # stands for a digit character.
*
* @param conventions used to convert between equinox-based and
* non-rotating-origin-based paradigms.
* @param itrfVersionProvider used to determine the ITRF version of parsed EOP.
* @param timeScales used to parse the EOP data.
* @return a new parser.
*/
static Parser newEopC04Parser(
final IERSConventions conventions,
final ItrfVersionProvider itrfVersionProvider,
final TimeScales timeScales) {
return new EOPC04FilesLoader.Parser(
conventions.getNutationCorrectionConverter(timeScales),
itrfVersionProvider,
timeScales.getUTC());
}
/**
* Create a new parser for EOP data in the Bulletin B format.
*
* @param conventions used to convert between equinox-based and
* non-rotating-origin-based paradigms.
* @param itrfVersionProvider used to determine the ITRF version of parsed EOP.
* @param timeScales used to parse the EOP data.
* @return a new parser.
*/
static Parser newBulletinBParser(
final IERSConventions conventions,
final ItrfVersionProvider itrfVersionProvider,
final TimeScales timeScales) {
return new BulletinBFilesLoader.Parser(
conventions.getNutationCorrectionConverter(timeScales),
itrfVersionProvider,
timeScales.getUTC());
}
}
}
package org.orekit.frames;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.orekit.data.DataLoader;
/**
* Implementation of {@link DataLoader} based on {@link EOPHistoryLoader.Parser} that
* loads all files and compiles the results into one data structure.
*
* @author Evan Ward
* @since 10.1
*/
class EopParserLoader implements DataLoader {
/** Parser for EOP data files. */
private final EOPHistoryLoader.Parser parser;
/** History entries. */
private final List<EOPEntry> history;
/**
* Create a {@link DataLoader} based on a {@link EOPHistoryLoader.Parser}. Loads
* all EOP data into a single collection.
*
* @param parser for the EOP data files.
*/
EopParserLoader(final EOPHistoryLoader.Parser parser) {
this.parser = parser;
this.history = new ArrayList<>();
}
/**
* Get the parsed EOP entries.
*
* @return the parsed EOP data. The returned collection is a reference, not a
* copy. It is not guaranteed to be sorted.
*/
public Collection<EOPEntry> getEop() {
return history;
}
/** {@inheritDoc} */
public boolean stillAcceptsData() {
return true;
}
@Override
public void loadData(final InputStream input, final String name)
throws IOException, ParseException {
history.addAll(parser.parse(input, name));
}
}
......@@ -16,6 +16,12 @@
*/
package org.orekit.frames;
import java.util.Collection;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import org.orekit.bodies.CelestialBodies;
import org.orekit.time.TimeScales;
import org.orekit.utils.IERSConventions;
/**
......@@ -256,4 +262,42 @@ public interface Frames {
FactoryManagedFrame getPZ9011(IERSConventions convention,
boolean simpleEOP);
/* Helpers for creating instances */
/**
* Create a set of frames from the given data.
*
* @param timeScales used to build the frames as well as the EOP data set.
* @param celestialBodies used to get {@link #getICRF()} which is the inertial frame
* of the solar system barycenter.
* @return a set of reference frame constructed from the given data.
* @see #of(TimeScales, Supplier)
*/
static Frames of(final TimeScales timeScales,
final CelestialBodies celestialBodies) {
return of(timeScales, () -> celestialBodies.getSolarSystemBarycenter()
.getInertiallyOrientedFrame());
}
/**
* Create a set of frames from the given data.
*
* @param timeScales used to build the frames as well as the EOP data set.
* @param icrfSupplier used to get {@link #getICRF()}. For example, {@code
* celestialBodies.getSolarSystemBarycenter().getInertiallyOrientedFrame()}
* @return a set of reference frame constructed from the given data.
* @see CelestialBodies
* @see TimeScales#of(Collection, BiFunction)
*/
static Frames of(final TimeScales timeScales,
final Supplier<Frame> icrfSupplier) {
return new AbstractFrames(timeScales, icrfSupplier) {
@Override
public EOPHistory getEOPHistory(final IERSConventions conventions,
final boolean simpleEOP) {
return getTimeScales().getUT1(conventions, simpleEOP).getEOPHistory();
}
};
}
}
......@@ -30,6 +30,7 @@ import org.orekit.errors.OrekitInternalError;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.time.TimeScalarFunction;
import org.orekit.time.TimeScale;
import org.orekit.time.TimeScales;
import org.orekit.time.UT1Scale;
import org.orekit.utils.Constants;
......@@ -62,7 +63,8 @@ public class GTODProvider implements EOPBasedTransformProvider {
/** Simple constructor.
*
* <p>This method uses the {@link DataContext#getDefault() default data context}.
* <p>This method uses the {@link DataContext#getDefault() default data context} if
* {@code eopHistory == null}.
*
* @param conventions IERS conventions to use
* @param eopHistory EOP history (may be null)
......@@ -72,7 +74,10 @@ public class GTODProvider implements EOPBasedTransformProvider {
@Deprecated
protected GTODProvider(final IERSConventions conventions,
final EOPHistory eopHistory) {
this(conventions, eopHistory, DataContext.getDefault().getTimeScales());
this(conventions, eopHistory,
eopHistory == null ?
DataContext.getDefault().getTimeScales() :
eopHistory.getTimeScales());
}
/** Simple constructor.
......@@ -84,7 +89,9 @@ public class GTODProvider implements EOPBasedTransformProvider {
protected GTODProvider(final IERSConventions conventions,
final EOPHistory eopHistory,
final TimeScales timeScales) {
final UT1Scale ut1 = timeScales.getUT1(eopHistory);
final TimeScale ut1 = eopHistory == null ?
timeScales.getUTC() : // UT1 wihthout EOP is UTC
timeScales.getUT1(eopHistory.getConventions(), eopHistory.isSimpleEop());
this.conventions = conventions;
this.eopHistory = eopHistory;
this.gastFunction = conventions.getGASTFunction(ut1, eopHistory, timeScales);
......
......@@ -61,7 +61,7 @@ import org.orekit.time.DateComponents;
* @author Luc Maisonobe
* @since 9.2
*/
public class ITRFVersionLoader {
public class ITRFVersionLoader implements ItrfVersionProvider {
/** Regular expression for supported files names. */
public static final String SUPPORTED_NAMES = "itrf-versions.conf";
......@@ -110,11 +110,7 @@ public class ITRFVersionLoader {
this(SUPPORTED_NAMES);
}
/** Get the ITRF version configuration defined by a given file at specified date.
* @param name EOP file name
* @param mjd date of the EOP in modified Julian day
* @return configuration valid around specified date in the file
*/
@Override
public ITRFVersionConfiguration getConfiguration(final String name, final int mjd) {
for (final ITRFVersionConfiguration configuration : configurations) {
......@@ -270,10 +266,10 @@ public class ITRFVersionLoader {
* @param validityStart start of validity (included)
* @param validityEnd end of validity (excluded)
*/
ITRFVersionConfiguration(final String prefix,
final ITRFVersion version,
final int validityStart,
final int validityEnd) {
public ITRFVersionConfiguration(final String prefix,
final ITRFVersion version,
final int validityStart,
final int validityEnd) {
this.prefix = prefix;
this.version = version;
this.validityStart = validityStart;
......
package org.orekit.frames;
import org.orekit.frames.ITRFVersionLoader.ITRFVersionConfiguration;
/**
* Interface for retrieving the ITRF version for a given set of EOP data.
*
* @author Luc Maisonobe
* @author Evan Ward
* @see ITRFVersionLoader
* @since 10.1
*/
public interface ItrfVersionProvider {
/**
* Get the ITRF version configuration defined by a given file at specified date.
*
* @param name EOP file name
* @param mjd date of the EOP in modified Julian day
* @return configuration valid around specified date in the file
*/
ITRFVersionConfiguration getConfiguration(String name, int mjd);
}
......@@ -22,13 +22,13 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.SortedSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.hipparchus.util.MathUtils;
import org.orekit.data.DataLoader;
import org.orekit.data.DataProvidersManager;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
......@@ -36,6 +36,7 @@ import org.orekit.time.AbsoluteDate;
import org.orekit.time.DateComponents;
import org.orekit.time.TimeScale;
import org.orekit.utils.IERSConventions;
import org.orekit.utils.IERSConventions.NutationCorrectionConverter;
/** Loader for IERS rapid data and prediction files in columns format (finals file).
* <p>Rapid data and prediction files contain {@link EOPEntry
......@@ -153,49 +154,42 @@ class RapidDataAndPredictionColumnsLoader extends AbstractEopLoader
/** {@inheritDoc} */
public void fillHistory(final IERSConventions.NutationCorrectionConverter converter,
final SortedSet<EOPEntry> history) {
final Parser parser = new Parser(converter, isNonRotatingOrigin);
this.feed(parser);
history.addAll(parser.history);
final ItrfVersionProvider itrfVersionProvider = new ITRFVersionLoader(
ITRFVersionLoader.SUPPORTED_NAMES,
getDataProvidersManager());
final Parser parser =
new Parser(converter, itrfVersionProvider, getUtc(), isNonRotatingOrigin);
final EopParserLoader loader = new EopParserLoader(parser);
this.feed(loader);
history.addAll(loader.getEop());
}
/** Internal class performing the parsing. */
private class Parser implements DataLoader {
/** Converter for nutation corrections. */
private final IERSConventions.NutationCorrectionConverter converter;
/** Configuration for ITRF versions. */
private final ITRFVersionLoader itrfVersionLoader;
static class Parser extends AbstractEopParser {
/** Indicator for Non-Rotating Origin. */
private final boolean isNonRotatingOrigin;
/** History entries. */
private final List<EOPEntry> history;
/** Simple constructor.
* @param converter converter to use
* @param itrfVersionProvider to use for determining the ITRF version of the EOP.
* @param utc time scale for parsing dates.
* @param isNonRotatingOrigin type of nutation correction
*/
Parser(final IERSConventions.NutationCorrectionConverter converter,
Parser(final NutationCorrectionConverter converter,
final ItrfVersionProvider itrfVersionProvider,
final TimeScale utc,
final boolean isNonRotatingOrigin) {
this.converter = converter;
this.itrfVersionLoader = new ITRFVersionLoader(
ITRFVersionLoader.SUPPORTED_NAMES,
getDataProvidersManager());
super(converter, itrfVersionProvider, utc);
this.isNonRotatingOrigin = isNonRotatingOrigin;
this.history = new ArrayList<>();
}
/** {@inheritDoc} */
public boolean stillAcceptsData() {
return true;
}
/** {@inheritDoc} */
public void loadData(final InputStream input, final String name)
@Override
public Collection<EOPEntry> parse(final InputStream input, final String name)
throws IOException {
final List<EOPEntry> history = new ArrayList<>();
ITRFVersionLoader.ITRFVersionConfiguration configuration = null;
// set up a reader for line-oriented bulletin B files
......@@ -301,13 +295,13 @@ class RapidDataAndPredictionColumnsLoader extends AbstractEopLoader
MILLI_ARC_SECONDS_TO_RADIANS * Double.parseDouble(nutationMatcher.group(1)),
MILLI_ARC_SECONDS_TO_RADIANS * Double.parseDouble(nutationMatcher.group(3))
};
equinox = converter.toEquinox(mjdDate, nro[0], nro[1]);
equinox = getConverter().toEquinox(mjdDate, nro[0], nro[1]);
} else {
equinox = new double[] {
MILLI_ARC_SECONDS_TO_RADIANS * Double.parseDouble(nutationMatcher.group(1)),
MILLI_ARC_SECONDS_TO_RADIANS * Double.parseDouble(nutationMatcher.group(3))
};
nro = converter.toNonRotating(mjdDate, equinox[0], equinox[1]);
nro = getConverter().toNonRotating(mjdDate, equinox[0], equinox[1]);
}
} else {
throw new OrekitException(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE,
......@@ -317,13 +311,14 @@ class RapidDataAndPredictionColumnsLoader extends AbstractEopLoader
if (configuration == null || !configuration.isValid(mjd)) {
// get a configuration for current name and date range
configuration = itrfVersionLoader.getConfiguration(name, mjd);
configuration = getItrfVersionProvider().getConfiguration(name, mjd);
}
history.add(new EOPEntry(mjd, dtu1, lod, x, y, equinox[0], equinox[1], nro[0], nro[1],
configuration.getVersion(), mjdDate));
}
return history;
}
}
......
......@@ -21,6 +21,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.SortedSet;
......@@ -28,7 +29,6 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import org.hipparchus.exception.LocalizedCoreFormats;
import org.orekit.data.DataLoader;
import org.orekit.data.DataProvidersManager;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
......@@ -84,43 +84,40 @@ class RapidDataAndPredictionXMLLoader extends AbstractEopLoader
/** {@inheritDoc} */
public void fillHistory(final IERSConventions.NutationCorrectionConverter converter,
final SortedSet<EOPEntry> history) {
final Parser parser = new Parser(converter);
this.feed(parser);
history.addAll(parser.history);
final ItrfVersionProvider itrfVersionProvider = new ITRFVersionLoader(
ITRFVersionLoader.SUPPORTED_NAMES,
getDataProvidersManager());
final Parser parser = new Parser(converter, itrfVersionProvider, getUtc());
final EopParserLoader loader = new EopParserLoader(parser);
this.feed(loader);
history.addAll(loader.getEop());
}
/** Internal class performing the parsing. */
private class Parser implements DataLoader {
/** Converter for nutation corrections. */
private final IERSConventions.NutationCorrectionConverter converter;
/** Configuration for ITRF versions. */
private final ITRFVersionLoader itrfVersionLoader;
static class Parser extends AbstractEopParser {
/** History entries. */
private final List<EOPEntry> history;
/** Simple constructor.
* @param converter converter to use
private List<EOPEntry> history;
/**
* Simple constructor.
*
* @param converter converter to use
* @param itrfVersionProvider to use for determining the ITRF version of the EOP.
* @param utc time scale for parsing dates.
*/
Parser(final IERSConventions.NutationCorrectionConverter converter) {
this.converter = converter;
this.itrfVersionLoader = new ITRFVersionLoader(
ITRFVersionLoader.SUPPORTED_NAMES,
getDataProvidersManager());
this.history = new ArrayList<>();
Parser(final IERSConventions.NutationCorrectionConverter converter,
final ItrfVersionProvider itrfVersionProvider,
final TimeScale utc) {
super(converter, itrfVersionProvider, utc);
}
/** {@inheritDoc} */
public boolean stillAcceptsData() {
return true;
}
/** {@inheritDoc} */
public void loadData(final InputStream input, final String name)
@Override
public Collection<EOPEntry> parse(final InputStream input, final String name)
throws IOException, OrekitException {
try {
this.history = new ArrayList<>();
// set up a reader for line-oriented bulletin B files
final XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
reader.setContentHandler(new EOPContentHandler(name));
......@@ -130,6 +127,8 @@ class RapidDataAndPredictionXMLLoader extends AbstractEopLoader
// read all file, ignoring header
reader.parse(new InputSource(new InputStreamReader(input, StandardCharsets.UTF_8)));
return history;
} catch (SAXException se) {
if ((se.getCause() != null) && (se.getCause() instanceof OrekitException)) {
throw (OrekitException) se.getCause();
......@@ -355,16 +354,16 @@ class RapidDataAndPredictionXMLLoader extends AbstractEopLoader
nro = new double[] {
dx, dy
};
equinox = converter.toEquinox(mjdDate, nro[0], nro[1]);
equinox = getConverter().toEquinox(mjdDate, nro[0], nro[1]);
} else {
equinox = new double[] {
dpsi, deps
};
nro = converter.toNonRotating(mjdDate, equinox[0], equinox[1]);
nro = getConverter().toNonRotating(mjdDate, equinox[0], equinox[1]);
}
if (configuration == null || !configuration.isValid(mjd)) {
// get a configuration for current name and date range
configuration = itrfVersionLoader.getConfiguration(name, mjd);
configuration = getItrfVersionProvider().getConfiguration(name, mjd);
}
history.add(new EOPEntry(mjd, dtu1, lod, x, y, equinox[0], equinox[1], nro[0], nro[1],
configuration.getVersion(), mjdDate));
......@@ -414,16 +413,16 @@ class RapidDataAndPredictionXMLLoader extends AbstractEopLoader
nro = new double[] {
dx, dy
};
equinox = converter.toEquinox(mjdDate, nro[0], nro[1]);
equinox = getConverter().toEquinox(mjdDate, nro[0], nro[1]);
} else {
equinox = new double[] {
dpsi, deps
};
nro = converter.toNonRotating(mjdDate, equinox[0], equinox[1]);
nro = getConverter().toNonRotating(mjdDate, equinox[0], equinox[1]);
}
if (configuration == null || !configuration.isValid(mjd)) {
// get a configuration for current name and date range
configuration = itrfVersionLoader.getConfiguration(name, mjd);
configuration = getItrfVersionProvider().getConfiguration(name, mjd);
}
history.add(new EOPEntry(mjd, dtu1, lod, x, y, equinox[0], equinox[1], nro[0], nro[1],
configuration.getVersion(), mjdDate));
......
package org.orekit.time;
import org.hipparchus.util.MathArrays;
import org.orekit.frames.EOPHistory;
import org.orekit.utils.Constants;
import org.orekit.utils.IERSConventions;
/**
* Abstract base class for {@link TimeScales} that implements some common functionality.
*
* @author Evan Ward
* @author Luc Maisonobe
* @since 10.1
*/
public abstract class AbstractTimeScales implements TimeScales {
/**
* Get the Universal Time 1 scale.
* <p>
* As this method allow associating any history with the time scale, it may involve
* large data sets. So this method does <em>not</em> cache the resulting {@link
* UT1Scale UT1Scale} instance, a new instance will be returned each time. In order to
* avoid wasting memory, calling {@link #getUT1(IERSConventions, boolean)} with the
* single enumerate corresponding to the conventions may be a better solution. This
* method is made available only for expert use.
* </p>
*
* @param history EOP parameters providing dUT1 (may be null if no correction is
* desired)
* @return Universal Time 1 scale
* @see #getUT1(IERSConventions, boolean)
*/
protected UT1Scale getUT1(final EOPHistory history) {
return new UT1Scale(history, getUTC());
}
@Override
public AbsoluteDate getJulianEpoch() {
return new AbsoluteDate(DateComponents.JULIAN_EPOCH, TimeComponents.H12, this.getTT());
}
@Override
public AbsoluteDate getModifiedJulianEpoch() {
return new AbsoluteDate(DateComponents.MODIFIED_JULIAN_EPOCH, TimeComponents.H00, this.getTT());
}
@Override
public AbsoluteDate getFiftiesEpoch() {
return new AbsoluteDate(DateComponents.FIFTIES_EPOCH, TimeComponents.H00, this.getTT());
}
@Override
public AbsoluteDate getCcsdsEpoch() {
return new AbsoluteDate(DateComponents.CCSDS_EPOCH, TimeComponents.H00, this.getTAI());
}
@Override
public AbsoluteDate getGalileoEpoch() {
return new AbsoluteDate(DateComponents.GALILEO_EPOCH, TimeComponents.H00, this.getGST());
}
@Override
public AbsoluteDate getGpsEpoch() {
return new AbsoluteDate(DateComponents.GPS_EPOCH, TimeComponents.H00, this.getGPS());
}
@Override
public AbsoluteDate getQzssEpoch() {
return new AbsoluteDate(DateComponents.QZSS_EPOCH, TimeComponents.H00, this.getQZSS());
}
@Override
public AbsoluteDate getIrnssEpoch() {
return new AbsoluteDate(DateComponents.IRNSS_EPOCH, TimeComponents.H00, this.getIRNSS());
}
@Override
public AbsoluteDate getBeidouEpoch() {
return new AbsoluteDate(DateComponents.BEIDOU_EPOCH, TimeComponents.H00, this.getBDT());
}
@Override
public AbsoluteDate getGlonassEpoch() {
return new AbsoluteDate(DateComponents.GLONASS_EPOCH,
new TimeComponents(29.0), this.getTAI()).shiftedBy(-10800.0);
}
@Override
public AbsoluteDate getJ2000Epoch() {
return new AbsoluteDate(DateComponents.J2000_EPOCH, TimeComponents.H12, this.getTT());
}
@Override
public AbsoluteDate getJavaEpoch() {
return new AbsoluteDate(DateComponents.JAVA_EPOCH, this.getTAI()).shiftedBy(8.000082);
}
@Override
public AbsoluteDate getPastInfinity() {
return getJavaEpoch().shiftedBy(Double.NEGATIVE_INFINITY);
}
@Override
public AbsoluteDate getFutureInfinity() {
return getJavaEpoch().shiftedBy(Double.POSITIVE_INFINITY);
}
@Override
public AbsoluteDate createJulianEpoch(final double julianEpoch) {
return new AbsoluteDate(getJ2000Epoch(),
Constants.JULIAN_YEAR * (julianEpoch - 2000.0));
}
@Override
public AbsoluteDate createBesselianEpoch(final double besselianEpoch) {
return new AbsoluteDate(getJ2000Epoch(),
MathArrays.linearCombination(
Constants.BESSELIAN_YEAR, besselianEpoch - 1900,
Constants.JULIAN_DAY, -36525,
Constants.JULIAN_DAY, 0.31352));
}
}
......@@ -39,7 +39,7 @@ import org.orekit.utils.IERSConventions;
* @see TimeScalesFactory
* @since 10.1
*/
public class LazyLoadedTimeScales implements TimeScales {
public class LazyLoadedTimeScales extends AbstractTimeScales {
/** Source of EOP data. */
private final LazyLoadedEop lazyLoadedEop;
......@@ -217,9 +217,11 @@ public class LazyLoadedTimeScales implements TimeScales {
}
}
// need to make this public for compatibility. Provides access to UT1 constructor.
/** {@inheritDoc} */
@Override
public UT1Scale getUT1(final EOPHistory history) {
return new UT1Scale(history, getUTC());
return super.getUT1(history);
}
@Override
......@@ -365,75 +367,4 @@ public class LazyLoadedTimeScales implements TimeScales {
}
}
@Override
public AbsoluteDate getJulianEpoch() {
return new AbsoluteDate(DateComponents.JULIAN_EPOCH, TimeComponents.H12, this.getTT());
}
@Override
public AbsoluteDate getModifiedJulianEpoch() {
return new AbsoluteDate(DateComponents.MODIFIED_JULIAN_EPOCH, TimeComponents.H00, this.getTT());
}
@Override
public AbsoluteDate getFiftiesEpoch() {
return new AbsoluteDate(DateComponents.FIFTIES_EPOCH, TimeComponents.H00, this.getTT());
}
@Override
public AbsoluteDate getCcsdsEpoch() {
return new AbsoluteDate(DateComponents.CCSDS_EPOCH, TimeComponents.H00, this.getTAI());
}
@Override
public AbsoluteDate getGalileoEpoch() {
return new AbsoluteDate(DateComponents.GALILEO_EPOCH, TimeComponents.H00, this.getGST());
}
@Override
public AbsoluteDate getGpsEpoch() {
return new AbsoluteDate(DateComponents.GPS_EPOCH, TimeComponents.H00, this.getGPS());
}
@Override
public AbsoluteDate getQzssEpoch() {
return new AbsoluteDate(DateComponents.QZSS_EPOCH, TimeComponents.H00, this.getQZSS());
}
@Override
public AbsoluteDate getIrnssEpoch() {
return new AbsoluteDate(DateComponents.IRNSS_EPOCH, TimeComponents.H00, this.getIRNSS());
}
@Override
public AbsoluteDate getBeidouEpoch() {
return new AbsoluteDate(DateComponents.BEIDOU_EPOCH, TimeComponents.H00, this.getBDT());
}
@Override
public AbsoluteDate getGlonassEpoch() {
return new AbsoluteDate(DateComponents.GLONASS_EPOCH,
new TimeComponents(29.0), this.getTAI()).shiftedBy(-10800.0);
}
@Override
public AbsoluteDate getJ2000Epoch() {
return new AbsoluteDate(DateComponents.J2000_EPOCH, TimeComponents.H12, this.getTT());
}
@Override
public AbsoluteDate getJavaEpoch() {
return new AbsoluteDate(DateComponents.JAVA_EPOCH, this.getTAI()).shiftedBy(8.000082);
}
@Override
public AbsoluteDate getPastInfinity() {
return getJavaEpoch().shiftedBy(Double.NEGATIVE_INFINITY);
}
@Override
public AbsoluteDate getFutureInfinity() {
return getJavaEpoch().shiftedBy(Double.POSITIVE_INFINITY);
}
}
package org.orekit.time;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.BiFunction;
import org.hipparchus.util.Pair;
import org.orekit.frames.EOPEntry;
import org.orekit.frames.EOPHistory;
import org.orekit.utils.IERSConventions;
/**
* A set of time scales that creates most time scales when constructed. The exceptions are
* {@link #getUT1(IERSConventions, boolean)} and {@link #getGMST(IERSConventions,
* boolean)} where six different instances exist based on conventions and simple EOP
* settings.
*
* @author Evan Ward
* @since 10.1
*/
class PreloadedTimeScales extends AbstractTimeScales {
/** TAI time scale. */
private final TAIScale tai;
/** UTC time scale. */
private final UTCScale utc;
/** TT time scale. */
private final TTScale tt;
/** Galileo time scale. */
private final GalileoScale gst;
/** GLONASS time scale. */
private final GLONASSScale glonass;
/** QZSS time scale. */
private final QZSSScale qzss;
/** GPS time scale. */
private final GPSScale gps;
/** TCG time scale. */
private final TCGScale tcg;
/** Tdb time scale. */
private final TDBScale tdb;
/** TCB time scale. */
private final TCBScale tcb;
/** IRNSS time scale. */
private final IRNSSScale irnss;
/** BDT time scale. */
private final BDTScale bdt;
/** Provider of EOP data. */
private final BiFunction<
? super IERSConventions,
? super TimeScales,
? extends Collection<? extends EOPEntry>> eopSupplier;
/** Cached EOP data. */
private final ConcurrentMap<IERSConventions, Collection<? extends EOPEntry>> eopMap;
/** UT1 time scales. */
private final ConcurrentMap<Pair<IERSConventions, Boolean>, UT1Scale> ut1Map;
/** GMST time scales. */
private final ConcurrentMap<Pair<IERSConventions, Boolean>, GMSTScale> gmstMap;
/**
* Create a new set of time scales from the given data.
*
* @param leapSeconds for UTC.
* @param eopSupplier provides EOP for UT1.
*/
PreloadedTimeScales(
final Collection<? extends OffsetModel> leapSeconds,
final BiFunction<
? super IERSConventions,
? super TimeScales,
? extends Collection<? extends EOPEntry>> eopSupplier) {
tai = new TAIScale();
tt = new TTScale();
gps = new GPSScale();
qzss = new QZSSScale();
gst = new GalileoScale();
irnss = new IRNSSScale();
bdt = new BDTScale();
tcg = new TCGScale(tt, tai);
utc = new UTCScale(tai, leapSeconds);
glonass = new GLONASSScale(utc);
tdb = new TDBScale(tt, getJ2000Epoch());
tcb = new TCBScale(tdb, tai);
final int n = IERSConventions.values().length;
eopMap = new ConcurrentHashMap<>(n);
ut1Map = new ConcurrentHashMap<>(n * 2);
gmstMap = new ConcurrentHashMap<>(n * 2);
this.eopSupplier = eopSupplier;
}
@Override
public TAIScale getTAI() {
return tai;
}
@Override
public UTCScale getUTC() {
return utc;
}
@Override
public UT1Scale getUT1(final IERSConventions conventions, final boolean simpleEOP) {
return ut1Map.computeIfAbsent(
new Pair<>(conventions, simpleEOP),
k -> getUT1(new EOPHistory(
conventions,
eopMap.computeIfAbsent(
conventions,
c -> eopSupplier.apply(c, this)),
simpleEOP,
this)));
}
@Override
public TTScale getTT() {
return tt;
}
@Override
public GalileoScale getGST() {
return gst;
}
@Override
public GLONASSScale getGLONASS() {
return glonass;
}
@Override
public QZSSScale getQZSS() {
return qzss;
}
@Override
public GPSScale getGPS() {
return gps;
}
@Override
public TCGScale getTCG() {
return tcg;
}
@Override
public TDBScale getTDB() {
return tdb;
}
@Override
public TCBScale getTCB() {
return tcb;
}
@Override
public GMSTScale getGMST(final IERSConventions conventions, final boolean simpleEOP) {
return gmstMap.computeIfAbsent(
new Pair<>(conventions, simpleEOP),
k -> new GMSTScale(getUT1(conventions, simpleEOP)));
}
@Override
public IRNSSScale getIRNSS() {
return irnss;
}
@Override
public BDTScale getBDT() {
return bdt;
}
}
......@@ -21,7 +21,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
......@@ -30,7 +29,6 @@ import java.util.regex.Pattern;
import org.hipparchus.util.FastMath;
import org.orekit.data.AbstractSelfFeedingLoader;
import org.orekit.data.DataContext;
import org.orekit.data.DataLoader;
import org.orekit.data.DataProvidersManager;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
......@@ -73,13 +71,13 @@ public class TAIUTCDatFilesLoader extends AbstractSelfFeedingLoader
/** {@inheritDoc} */
@Override
public List<OffsetModel> loadOffsets() {
final Parser parser = new Parser();
final UtcTaiOffsetLoader parser = new UtcTaiOffsetLoader(new Parser());
this.feed(parser);
return parser.getOffsets();
}
/** Internal class performing the parsing. */
private static class Parser implements DataLoader {
public static class Parser implements UTCTAIOffsetsLoader.Parser {
/** Regular expression for optional blanks. */
private static final String BLANKS = "\\p{Blank}*";
......@@ -114,12 +112,9 @@ public class TAIUTCDatFilesLoader extends AbstractSelfFeedingLoader
/** Data lines pattern. */
private Pattern dataPattern;
/** UTC-TAI offsets. */
private List<OffsetModel> offsets;
/** Simple constructor.
*/
Parser() {
public Parser() {
// data lines read:
// 1965 SEP 1 =JD 2439004.5 TAI-UTC= 3.8401300 S + (MJD - 38761.) X 0.001296 S
......@@ -148,20 +143,7 @@ public class TAIUTCDatFilesLoader extends AbstractSelfFeedingLoader
"\\p{Blank}*\\)\\p{Blank}+X" + STORED_REAL_FIELD +
"\\p{Blank}*S" + LINE_END_REGEXP);
offsets = new ArrayList<>();
}
/** Get the parsed offsets.
* @return parsed offsets
*/
public List<OffsetModel> getOffsets() {