Commit c8cf9c23 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Fixed compiler warnings.

parent 35b6aa85
......@@ -16,6 +16,8 @@
*/
package org.orekit.propagation.events;
import java.lang.reflect.Array;
import org.hipparchus.Field;
import org.hipparchus.RealFieldElement;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
......@@ -37,6 +39,7 @@ import org.orekit.propagation.events.handlers.FieldEventHandler;
import org.orekit.propagation.numerical.FieldNumericalPropagator;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.time.FieldTimeStamped;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.FieldPVCoordinates;
......@@ -91,7 +94,8 @@ public class FieldDateDetectorTest {
propagator.setOrbitType(OrbitType.EQUINOCTIAL);
propagator.setInitialState(initialState);
FieldDateDetector<T> dateDetector = new FieldDateDetector<>(zero.add(maxCheck), zero.add(threshold), iniDate.shiftedBy(2.0*dt));
FieldDateDetector<T> dateDetector = new FieldDateDetector<>(zero.add(maxCheck), zero.add(threshold),
toArray(iniDate.shiftedBy(2.0*dt)));
Assert.assertEquals(2 * dt, dateDetector.getDate().durationFrom(iniDate).getReal(), 1.0e-10);
propagator.addEventDetector(dateDetector);
final FieldSpacecraftState<T> finalState = propagator.propagate(iniDate.shiftedBy(100.*dt));
......@@ -120,7 +124,9 @@ public class FieldDateDetectorTest {
FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, integrator);
propagator.setOrbitType(OrbitType.EQUINOCTIAL);
propagator.setInitialState(initialState);
FieldDateDetector<T> dateDetector = new FieldDateDetector<>(zero.add(maxCheck), zero.add(threshold));
@SuppressWarnings("unchecked")
FieldDateDetector<T> dateDetector = new FieldDateDetector<>(zero.add(maxCheck), zero.add(threshold),
(FieldTimeStamped<T>[]) Array.newInstance(FieldTimeStamped.class, 0));
Assert.assertNull(dateDetector.getDate());
FieldEventDetector<T> nodeDetector = new FieldNodeDetector<>(iniOrbit, iniOrbit.getFrame()).
withHandler(new FieldContinueOnEvent<FieldNodeDetector<T>, T>() {
......@@ -163,7 +169,8 @@ public class FieldDateDetectorTest {
propagator.setOrbitType(OrbitType.EQUINOCTIAL);
propagator.setInitialState(initialState);
FieldDateDetector<T> dateDetector = new FieldDateDetector<>(zero.add(maxCheck), zero.add(threshold), iniDate.shiftedBy(-dt)).
FieldDateDetector<T> dateDetector = new FieldDateDetector<>(zero.add(maxCheck), zero.add(threshold),
toArray(iniDate.shiftedBy(-dt))).
withHandler(new FieldContinueOnEvent<FieldDateDetector<T>, T >() {
public Action eventOccurred(FieldSpacecraftState<T> s, FieldDateDetector<T> dd, boolean increasing)
throws OrekitException {
......@@ -200,7 +207,8 @@ public class FieldDateDetectorTest {
propagator.setOrbitType(OrbitType.EQUINOCTIAL);
propagator.setInitialState(initialState);
FieldDateDetector<T> dateDetector = new FieldDateDetector<>(zero.add(maxCheck), zero.add(threshold), iniDate.shiftedBy(dt)).
FieldDateDetector<T> dateDetector = new FieldDateDetector<>(zero.add(maxCheck), zero.add(threshold),
toArray(iniDate.shiftedBy(dt))).
withHandler(new FieldContinueOnEvent<FieldDateDetector<T>, T >() {
public Action eventOccurred(FieldSpacecraftState<T> s, FieldDateDetector<T> dd, boolean increasing)
throws OrekitException {
......@@ -243,7 +251,8 @@ public class FieldDateDetectorTest {
propagator.setInitialState(initialState);
//setup
final FieldDateDetector<T> dateDetector = new FieldDateDetector<>(zero.add(maxCheck), zero.add(threshold), iniDate.shiftedBy(dt));
final FieldDateDetector<T> dateDetector = new FieldDateDetector<>(zero.add(maxCheck), zero.add(threshold),
toArray(iniDate.shiftedBy(dt)));
// generic event handler that works with all detectors.
FieldEventHandler<FieldEventDetector<T>, T> handler = new FieldEventHandler<FieldEventDetector<T>, T>() {
@Override
......@@ -274,6 +283,13 @@ public class FieldDateDetectorTest {
Assert.assertEquals(dt, finalState.getDate().durationFrom(iniDate).getReal(), threshold);
}
private <T extends RealFieldElement<T>> FieldTimeStamped<T>[] toArray(final FieldAbsoluteDate<T> date) {
@SuppressWarnings("unchecked")
final FieldTimeStamped<T>[] array = (FieldTimeStamped<T>[]) Array.newInstance(FieldTimeStamped.class, 1);
array[0] = date;
return array;
}
@Before
public void setUp() {
Utils.setDataRoot("regular-data");
......
......@@ -16,6 +16,8 @@
*/
package org.orekit.propagation.numerical;
import java.lang.reflect.Array;
import org.hamcrest.MatcherAssert;
import org.hipparchus.Field;
import org.hipparchus.RealFieldElement;
......@@ -75,6 +77,7 @@ import org.orekit.propagation.integration.FieldAdditionalEquations;
import org.orekit.propagation.sampling.FieldOrekitStepHandler;
import org.orekit.propagation.sampling.FieldOrekitStepInterpolator;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.time.FieldTimeStamped;
import org.orekit.time.TimeScale;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.Constants;
......@@ -132,7 +135,7 @@ public class FieldNumericalPropagatorTest {
propagator.propagate(end);
FieldBoundedPropagator<T> ephemeris = propagator.getGeneratedEphemeris();
CountingHandler<D, T> handler = new CountingHandler<D, T>();
FieldDateDetector<T> detector = new FieldDateDetector<>(zero.add(10), zero.add(1e-9), end).withHandler(handler);
FieldDateDetector<T> detector = new FieldDateDetector<>(zero.add(10), zero.add(1e-9), toArray(end)).withHandler(handler);
// propagation works fine w/o event detector, but breaks with it
ephemeris.addEventDetector(detector);
......@@ -168,7 +171,7 @@ public class FieldNumericalPropagatorTest {
// events directly on propagation start date are not triggered,
// so move the event date slightly after
FieldAbsoluteDate<T> eventDate = initDate.shiftedBy(FastMath.ulp(100.0) / 10.0);
FieldDateDetector<T> detector = new FieldDateDetector<>(zero.add(10), zero.add(1e-9), eventDate)
FieldDateDetector<T> detector = new FieldDateDetector<>(zero.add(10), zero.add(1e-9), toArray(eventDate))
.withHandler(handler);
// propagation works fine w/o event detector, but breaks with it
ephemeris.addEventDetector(detector);
......@@ -219,9 +222,9 @@ public class FieldNumericalPropagatorTest {
FieldAbsoluteDate<T> initDate = propagator.getInitialState().getDate();
// setup
FieldDateDetector<T> d1 = new FieldDateDetector<>(zero.add(10), zero.add(1), initDate.shiftedBy(15))
FieldDateDetector<T> d1 = new FieldDateDetector<>(zero.add(10), zero.add(1), toArray(initDate.shiftedBy(15)))
.withHandler(new FieldContinueOnEvent<FieldDateDetector<T>, T>());
FieldDateDetector<T> d2 = new FieldDateDetector<>(zero.add(10), zero.add(1), initDate.shiftedBy(15.5))
FieldDateDetector<T> d2 = new FieldDateDetector<>(zero.add(10), zero.add(1), toArray(initDate.shiftedBy(15.5)))
.withHandler(new FieldContinueOnEvent<FieldDateDetector<T>, T>());
propagator.addEventDetector(d1);
propagator.addEventDetector(d2);
......@@ -1599,12 +1602,15 @@ public class FieldNumericalPropagatorTest {
error60s,
error120s, error300s,
error600s, error900s);
np.addEventDetector(new FieldDateDetector<>(zero.add(30.0), zero.add(1.0e-9), reference,
reference.shiftedBy( 60.0),
reference.shiftedBy(120.0),
reference.shiftedBy(300.0),
reference.shiftedBy(600.0),
reference.shiftedBy(900.0)).
@SuppressWarnings("unchecked")
FieldTimeStamped<T>[] dates = (FieldTimeStamped<T>[]) Array.newInstance(FieldTimeStamped.class, 6);
dates[0] = reference;
dates[1] = reference.shiftedBy( 60.0);
dates[2] = reference.shiftedBy(120.0);
dates[3] = reference.shiftedBy(300.0);
dates[4] = reference.shiftedBy(600.0);
dates[5] = reference.shiftedBy(900.0);
np.addEventDetector(new FieldDateDetector<T>(zero.add(30.0), zero.add(1.0e-9), (FieldTimeStamped<T>[]) dates).
withHandler(checker));
np.propagate(reference.shiftedBy(1000.0));
}
......@@ -1816,6 +1822,13 @@ public class FieldNumericalPropagatorTest {
return propagator;
}
private <T extends RealFieldElement<T>> FieldTimeStamped<T>[] toArray(final FieldAbsoluteDate<T> date) {
@SuppressWarnings("unchecked")
final FieldTimeStamped<T>[] array = (FieldTimeStamped<T>[]) Array.newInstance(FieldTimeStamped.class, 1);
array[0] = date;
return array;
}
@Before
public void setUp() throws OrekitException {
Utils.setDataRoot("regular-data:potential/shm-format");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment