use of org.hipparchus.exception.DummyLocalizable in project Orekit by CS-SI.
the class SolarInputs97to05 method findClosestLine.
private void findClosestLine(AbsoluteDate date) throws OrekitException {
if ((date.durationFrom(firstDate) < 0) || (date.durationFrom(lastDate) > Constants.JULIAN_DAY)) {
throw new OrekitException(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, date, firstDate, lastDate);
}
// don't search if the cached selection is fine
if ((currentParam != null) && (date.durationFrom(currentParam.date) >= 0) && (date.durationFrom(currentParam.date) < Constants.JULIAN_DAY)) {
return;
}
LineParameters before = new LineParameters(date.shiftedBy(-Constants.JULIAN_DAY), null, 0, 0, 0, 0, 0, 0);
// search starting from entries a few steps before the target date
SortedSet<TimeStamped> tailSet = data.tailSet(before);
if (tailSet != null) {
currentParam = (LineParameters) tailSet.first();
if (currentParam.date.durationFrom(date) == -Constants.JULIAN_DAY) {
currentParam = (LineParameters) data.tailSet(date).first();
}
} else {
throw new OrekitException(new DummyLocalizable("unable to find data for date {0}"), date);
}
}
use of org.hipparchus.exception.DummyLocalizable in project Orekit by CS-SI.
the class DataProvidersManagerTest method testListModification.
@Test
public void testListModification() throws OrekitException {
System.setProperty(DataProvidersManager.OREKIT_DATA_PATH, getPath("regular-data"));
CountingLoader crawler = new CountingLoader(false);
DataProvidersManager manager = DataProvidersManager.getInstance();
manager.clearProviders();
Assert.assertFalse(manager.isSupported(new DirectoryCrawler(new File(getPath("regular-data")))));
Assert.assertTrue(manager.feed(".*", crawler));
Assert.assertTrue(crawler.getCount() > 0);
List<DataProvider> providers = manager.getProviders();
Assert.assertEquals(1, providers.size());
for (DataProvider provider : providers) {
Assert.assertTrue(manager.isSupported(provider));
}
Assert.assertNotNull(manager.removeProvider(providers.get(0)));
Assert.assertEquals(0, manager.getProviders().size());
DataProvider provider = new DataProvider() {
public boolean feed(Pattern supported, DataLoader visitor) throws OrekitException {
return true;
}
};
manager.addProvider(provider);
Assert.assertEquals(1, manager.getProviders().size());
manager.addProvider(provider);
Assert.assertEquals(2, manager.getProviders().size());
Assert.assertNotNull(manager.removeProvider(provider));
Assert.assertEquals(1, manager.getProviders().size());
Assert.assertNull(manager.removeProvider(new DataProvider() {
public boolean feed(Pattern supported, DataLoader visitor) throws OrekitException {
throw new OrekitException(new DummyLocalizable("oops!"));
}
}));
Assert.assertEquals(1, manager.getProviders().size());
Assert.assertNotNull(manager.removeProvider(manager.getProviders().get(0)));
Assert.assertEquals(0, manager.getProviders().size());
}
use of org.hipparchus.exception.DummyLocalizable in project Orekit by CS-SI.
the class KeplerianPropagatorTest method tesWrapedAttitudeException.
@Test(expected = OrekitException.class)
public void tesWrapedAttitudeException() throws OrekitException {
final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
KeplerianPropagator propagator = new KeplerianPropagator(orbit, new AttitudeProvider() {
private static final long serialVersionUID = 1L;
public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
});
propagator.propagate(orbit.getDate().shiftedBy(10.09));
}
use of org.hipparchus.exception.DummyLocalizable in project Orekit by CS-SI.
the class KeplerianPropagatorTest method wrongAttitude.
@Test(expected = OrekitException.class)
public void wrongAttitude() throws OrekitException {
KeplerianOrbit orbit = new KeplerianOrbit(1.0e10, 1.0e-4, 1.0e-2, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
AttitudeProvider wrongLaw = new AttitudeProvider() {
private static final long serialVersionUID = 5918362126173997016L;
public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
}
public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
}
};
KeplerianPropagator propagator = new KeplerianPropagator(orbit, wrongLaw);
propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0));
}
use of org.hipparchus.exception.DummyLocalizable in project Orekit by CS-SI.
the class KeplerianPropagatorTest method testStepException.
@Test(expected = OrekitException.class)
public void testStepException() throws OrekitException {
final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
KeplerianPropagator propagator = new KeplerianPropagator(orbit);
OrekitStepHandlerMultiplexer multiplexer = new OrekitStepHandlerMultiplexer();
propagator.setMasterMode(multiplexer);
multiplexer.add(new OrekitStepHandler() {
public void init(SpacecraftState s0, AbsoluteDate t) {
}
public void handleStep(OrekitStepInterpolator interpolator, boolean isLast) throws OrekitException {
if (isLast) {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
}
});
propagator.propagate(orbit.getDate().shiftedBy(-3600));
}
Aggregations