Commit b3eda988 authored by Luc Maisonobe's avatar Luc Maisonobe

Fixed findbugs warnings.

parent bf555d2e
......@@ -43,6 +43,11 @@
<Class name="~.*\.GeographicZoneDetector$" />
<Class name="~.*\.SaastamoinenModel$" />
<Class name="~.*\.EventEnablingPredicateFilter$" />
<Class name="~.*\.FixedTransformProvider$" />
<Class name="~.*\.InterpolatingTransformProvider$" />
<Class name="~.*\.ShiftingTransformProvider$" />
<Class name="~.*\.MODProvider$" />
<Class name="~.*\.TIRFProvider$" />
</Or>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
......
......@@ -79,7 +79,7 @@ public class OrekitEphemerisFile implements EphemerisFile {
* {@link OrekitSatelliteEphemeris} corresponding object for this ephemeris type.
*
*/
public class OrekitSatelliteEphemeris implements SatelliteEphemeris {
public static class OrekitSatelliteEphemeris implements SatelliteEphemeris {
/**
* Defines the default interpolation sample size if it is not specified
* on a segment.
......@@ -231,7 +231,7 @@ public class OrekitEphemerisFile implements EphemerisFile {
}
}
public class OrekitEphemerisSegment implements EphemerisSegment {
public static class OrekitEphemerisSegment implements EphemerisSegment {
/** **/
private final List<TimeStampedPVCoordinates> coordinates;
......
......@@ -40,7 +40,7 @@ import org.orekit.utils.PVCoordinatesProvider;
* @author Luc Maisonobe
* @deprecated as of 9.0, this class is considered ill-designed. Instead of using this
* class and its {@link #getTransformTo(Frame, AbsoluteDate) getTransformTo} method,
* which will cause an orbit propagation to be pefformed under the hood, a better
* which will cause an orbit propagation to be performed under the hood, a better
* alternative is to use {@link org.orekit.propagation.SpacecraftState#toTransform()}
* from within the orbit propagator, at each time step.
*/
......@@ -94,7 +94,7 @@ public class LocalOrbitalFrame extends Frame {
private final PVCoordinatesProvider provider;
/** Cached field-based transforms. */
private final transient Map<Field<? extends RealFieldElement<?>>, FieldPVCoordinatesProvider<? extends RealFieldElement<?>>> fieldProviders;
private transient Map<Field<? extends RealFieldElement<?>>, FieldPVCoordinatesProvider<? extends RealFieldElement<?>>> fieldProviders;
/** Reference frame. */
private final Frame reference;
......@@ -147,6 +147,18 @@ public class LocalOrbitalFrame extends Frame {
}
/** Ensure fieldProviders is properly set.
* @return fixed instance
*/
private Object readResolve() {
// this is really an ugly hack, intended only to prevent findbugs complaining
// anyway, the class is deprecated and already ill-designed
if (fieldProviders == null) {
fieldProviders = new HashMap<>();
}
return this;
}
}
}
......@@ -22,7 +22,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.function.DoubleBinaryOperator;
import org.hipparchus.util.FastMath;
import org.orekit.errors.OrekitException;
......@@ -68,7 +67,7 @@ public class BooleanDetector extends AbstractDetector<BooleanDetector> {
private final List<EventDetector> detectors;
/** The composition function. Should be associative for predictable behavior. */
private final DoubleBinaryOperator operator;
private final Operator operator;
/**
* Private constructor with all the parameters.
......@@ -82,7 +81,7 @@ public class BooleanDetector extends AbstractDetector<BooleanDetector> {
* @param newHandler event handler.
*/
private BooleanDetector(final List<EventDetector> detectors,
final DoubleBinaryOperator operator,
final Operator operator,
final double newMaxCheck,
final double newThreshold,
final int newMaxIter,
......@@ -138,7 +137,7 @@ public class BooleanDetector extends AbstractDetector<BooleanDetector> {
final Collection<? extends EventDetector> detectors) {
return new BooleanDetector(new ArrayList<>(detectors), // copy for immutability
FastMath::min,
Operator.AND,
detectors.stream().map(EventDetector::getMaxCheckInterval).min(Double::compareTo).get(),
detectors.stream().map(EventDetector::getThreshold).min(Double::compareTo).get(),
detectors.stream().map(EventDetector::getMaxIterationCount).min(Integer::compareTo).get(),
......@@ -191,7 +190,7 @@ public class BooleanDetector extends AbstractDetector<BooleanDetector> {
final Collection<? extends EventDetector> detectors) {
return new BooleanDetector(new ArrayList<>(detectors), // copy for immutability
FastMath::max,
Operator.OR,
detectors.stream().map(EventDetector::getMaxCheckInterval).min(Double::compareTo).get(),
detectors.stream().map(EventDetector::getThreshold).min(Double::compareTo).get(),
detectors.stream().map(EventDetector::getMaxIterationCount).min(Integer::compareTo).get(),
......@@ -229,7 +228,7 @@ public class BooleanDetector extends AbstractDetector<BooleanDetector> {
ret = detector.g(s);
first = false;
} else {
ret = this.operator.applyAsDouble(ret, detector.g(s));
ret = operator.combine(ret, detector.g(s));
}
}
// return the result of applying the operator to all operands
......@@ -253,4 +252,38 @@ public class BooleanDetector extends AbstractDetector<BooleanDetector> {
}
}
/** Local, serializable class for operator. */
private enum Operator {
/** And operator. */
AND() {
@Override
/** {@inheritDoc} */
public double combine(final double g1, final double g2) {
return FastMath.min(g1, g2);
}
},
/** Or operator. */
OR() {
@Override
/** {@inheritDoc} */
public double combine(final double g1, final double g2) {
return FastMath.max(g1, g2);
}
};
/** Combine two g functions evaluations.
* @param g1 first evaluation
* @param g2 second evaluation
* @return combined evaluation
*/
public abstract double combine(double g1, double g2);
};
}
package fr.cs.examples.propagation;
import java.io.FileWriter;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;
......@@ -65,11 +65,11 @@ public class FieldPropagation {
Autoconfiguration.configureOrekit();
//setting some filewriter and printwriter to have the output
String workingDir = System.getProperty("user.dir");
System.out.println("Output file is in : " + workingDir + "/error.txt");
FileWriter FW = new FileWriter(workingDir + "/error.txt", false);
PrintWriter PW = new PrintWriter(FW);
//setting some the file
File workingDir = new File(System.getProperty("user.dir"));
File errorFile = new File(workingDir, "error.txt");
System.out.println("Output file is in : " + errorFile.getAbsolutePath());
PrintWriter PW = new PrintWriter(errorFile, "UTF-8");
PW.printf("time \t\tCrossTrackErr \tLongTrackErr \tRadialErr \tTotalErr%n");
......@@ -249,11 +249,11 @@ public class FieldPropagation {
//printing all the standard deviations on the file error.txt
Locale.setDefault(new Locale("en", "US"));
PW.printf("%f \t", currentState.getDate().durationFrom(data_0).getReal()/3600);
PW.printf("%f \t", stat_CT.getStandardDeviation());
PW.printf("%f \t", stat_LT.getStandardDeviation());
PW.printf("%f \t", stat_R.getStandardDeviation());
PW.printf("%f \n", stat_dist.getStandardDeviation());
PW.printf("%f\t", currentState.getDate().durationFrom(data_0).getReal()/3600);
PW.printf("%f\t", stat_CT.getStandardDeviation());
PW.printf("%f\t", stat_LT.getStandardDeviation());
PW.printf("%f\t", stat_R.getStandardDeviation());
PW.printf("%f%n", stat_dist.getStandardDeviation());
}
......
Markdown is supported
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