Skip to content
Snippets Groups Projects
Commit 46628665 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Added an isInRange(AbsoluteDate) method.

This method allows caller to make sure a direct location call will not
generate an exception dut to date out of range.
parent 07b49291
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment