use of org.orekit.errors.OrekitIllegalArgumentException in project Orekit by CS-SI.
the class DateDetector method addEventDate.
/**
* Add an event date.
* <p>The date to add must be:</p>
* <ul>
* <li>less than the smallest already registered event date minus the maxCheck</li>
* <li>or more than the largest already registered event date plus the maxCheck</li>
* </ul>
* @param target target date
* @throws IllegalArgumentException if the date is too close from already defined interval
* @see #DateDetector(double, double, TimeStamped...)
*/
public void addEventDate(final AbsoluteDate target) throws IllegalArgumentException {
final boolean increasing;
if (currentIndex < 0) {
increasing = (gDate == null) ? true : target.durationFrom(gDate) > 0.0;
currentIndex = 0;
eventDateList.add(new EventDate(target, increasing));
} else {
final int lastIndex = eventDateList.size() - 1;
if (eventDateList.get(0).getDate().durationFrom(target) > getMaxCheckInterval()) {
increasing = !eventDateList.get(0).isgIncrease();
eventDateList.add(0, new EventDate(target, increasing));
currentIndex++;
} else if (target.durationFrom(eventDateList.get(lastIndex).getDate()) > getMaxCheckInterval()) {
increasing = !eventDateList.get(lastIndex).isgIncrease();
eventDateList.add(new EventDate(target, increasing));
} else {
throw new OrekitIllegalArgumentException(OrekitMessages.EVENT_DATE_TOO_CLOSE, target, eventDateList.get(0).getDate(), eventDateList.get(lastIndex).getDate(), getMaxCheckInterval());
}
}
}
Aggregations