diff --git a/core/src/main/java/org/orekit/rugged/api/Rugged.java b/core/src/main/java/org/orekit/rugged/api/Rugged.java index 214aa1d3aad86f04db7761709f753bab8359e498..e75551c34402e571be5f10a3a31b296862432fe0 100644 --- a/core/src/main/java/org/orekit/rugged/api/Rugged.java +++ b/core/src/main/java/org/orekit/rugged/api/Rugged.java @@ -722,6 +722,22 @@ public class Rugged { } + /** Check if a date is in the supported range. + * <p> + * The supporte range is given by the {@code minDate} and + * {@code maxDate} construction parameters, with an {@code + * overshootTolerance} margin accepted (i.e. a date slightly + * before {@code minDate} or slightly after {@code maxDate} + * will be considered in range if the overshoot does not exceed + * the tolerance set at construction). + * </p> + * @param date date to check + * @return true if date is in the supported range + */ + public boolean isInRange(final AbsoluteDate date) { + return scToBody.isInRange(date); + } + /** Direct location of a sensor line. * @param sensorName name of the line sensor * @param lineNumber number of the line to localize on ground diff --git a/core/src/main/java/org/orekit/rugged/utils/SpacecraftToObservedBody.java b/core/src/main/java/org/orekit/rugged/utils/SpacecraftToObservedBody.java index c0c2db581255a2a19e725b4969ee8ccc8ca84bde..0d706bdd80fea1f88237da7605dc4c532aee3b9f 100644 --- a/core/src/main/java/org/orekit/rugged/utils/SpacecraftToObservedBody.java +++ b/core/src/main/java/org/orekit/rugged/utils/SpacecraftToObservedBody.java @@ -250,10 +250,7 @@ public class SpacecraftToObservedBody implements Serializable { throws RuggedException { // check date range - if (minDate.durationFrom(date) > overshootTolerance) { - throw new RuggedException(RuggedMessages.OUT_OF_TIME_RANGE, date, minDate, maxDate); - } - if (date.durationFrom(maxDate) > overshootTolerance) { + if (!isInRange(date)) { throw new RuggedException(RuggedMessages.OUT_OF_TIME_RANGE, date, minDate, maxDate); } @@ -264,4 +261,13 @@ public class SpacecraftToObservedBody implements Serializable { } + /** Check if a date is in the supported range. + * @param date date to check + * @return true if date is in the supported range + */ + public boolean isInRange(final AbsoluteDate date) { + return (minDate.durationFrom(date) <= overshootTolerance) && + (date.durationFrom(maxDate) <= overshootTolerance); + } + }