Hello,
I would like to use DateDetector
to retrieve the state of an orbit within a specific time sequence, but it is not working as expected. The contents of the eventOccurred
method are not being triggered. Here is my code for reference.
final TLE tle = new TLE("1 48251U 21033D 24100.92177916 .00068874 00000+0 13229-2 0 9999", "2 48251 97.2783 177.1897 0013115 174.7574 185.3817 15.47627235164785");
orbit = getOrbitByTLE(tle, OrekitContext.frame, 192);
final TLEPropagator propagator = TLEPropagator.selectExtrapolator(tle);
DateDetector dateDetector = new DateDetector(1, DateDetector.DEFAULT_THRESHOLD);
for (int i = 0; i < dates.size(); i++) {
AbsoluteDate absoluteDate = new AbsoluteDate(dates.get(i), TimeScalesFactory.getUTC());
dateDetector.addEventDate(absoluteDate);
}
List<Orbit> orbits = new ArrayList<>();
dateDetector.withHandler(new EventHandler<DateDetector>() {
@Override
public Action eventOccurred(SpacecraftState s, DateDetector detector, boolean increasing) {
orbits.add(s.getOrbit());
return Action.CONTINUE;
}
});
propagator.addEventDetector(dateDetector);
propagator.propagate(orbit.getDate(), new AbsoluteDate(dates.get(dates.size() - 1), TimeScalesFactory.getUTC()).shiftedBy(100));