Commit 4e8e394a authored by Luc Maisonobe's avatar Luc Maisonobe

Fixed compilation problems with JDK 1.8.

Fixes issue #462.
parent 9b2936aa
/* Copyright 2002-2018 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.estimation.measurements;
import org.orekit.time.TimeStamped;
/** Base interface for comparing measurements regardless of thei type.
* @author Luc Maisonobe
* @since 9.2
*/
public interface ComparableMeasurement extends TimeStamped, Comparable<ComparableMeasurement> {
/** Get the observed value.
* <p>
* The observed value is the value that was measured by the instrument.
* </p>
* @return observed value (array of size {@link #getDimension()}
*/
double[] getObservedValue();
/** {@inheritDoc}
* <p>
* Measurements comparison is primarily chronological, but measurements
* with the same date are sorted based on the observed value. Even if they
* have the same value too, they will <em>not</em> be considered equal if they
* correspond to different instances. This allows to store measurements in
* {@link java.util.SortedSet SortedSet} without losing any measurements, even
* redundant ones.
* </p>
*/
@Override
default int compareTo(final ComparableMeasurement other) {
if (this == other) {
// only case where measurements are considered equal
return 0;
}
int result = getDate().compareTo(other.getDate());
if (result == 0) {
// simultaneous measurements, we compare values
final double[] thisV = getObservedValue();
final double[] otherV = other.getObservedValue();
if (thisV.length > otherV.length) {
result = +1;
} else if (thisV.length < otherV.length) {
result = 1;
} else {
for (int i = 0; i < thisV.length && result == 0; ++i) {
result = Double.compare(thisV[i], otherV[i]);
}
if (result == 0) {
// measurements have the same value,
// but we do not want them to appear as equal
// we set up an arbitrary order
result = -1;
}
}
}
return result;
}
}
......@@ -24,7 +24,6 @@ import org.orekit.errors.OrekitIllegalArgumentException;
import org.orekit.errors.OrekitMessages;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.TimeStamped;
import org.orekit.utils.ParameterDriver;
import org.orekit.utils.TimeStampedPVCoordinates;
......@@ -33,8 +32,7 @@ import org.orekit.utils.TimeStampedPVCoordinates;
* @author Luc Maisonobe
* @since 8.0
*/
public class EstimatedMeasurement<T extends ObservedMeasurement<T>>
implements TimeStamped, Comparable<EstimatedMeasurement<T>> {
public class EstimatedMeasurement<T extends ObservedMeasurement<T>> implements ComparableMeasurement {
/** Associated observed measurement. */
private final T observedMeasurement;
......@@ -148,6 +146,12 @@ public class EstimatedMeasurement<T extends ObservedMeasurement<T>>
return observedMeasurement.getDate().durationFrom(states[0].getDate());
}
/** {@inheritDoc} */
@Override
public double[] getObservedValue() {
return observedMeasurement.getObservedValue();
}
/** Get the estimated value.
* @return estimated value
*/
......@@ -275,17 +279,6 @@ public class EstimatedMeasurement<T extends ObservedMeasurement<T>>
parametersDerivatives.put(driver, parameterDerivatives);
}
/** {@inheritDoc}
* <p>
* Measurements comparison is based on the underlying observed measurement only.
* </p>
* @since 9.2
*/
@Override
public int compareTo(final EstimatedMeasurement<T> other) {
return observedMeasurement.compareTo(other.getObservedMeasurement());
}
/** Enumerate for the status of the measurement. */
public enum Status {
......
......@@ -20,7 +20,6 @@ import java.util.List;
import org.orekit.errors.OrekitException;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.TimeStamped;
import org.orekit.utils.ParameterDriver;
......@@ -42,8 +41,7 @@ import org.orekit.utils.ParameterDriver;
* @author Luc Maisonobe
* @since 8.0
*/
public interface ObservedMeasurement<T extends ObservedMeasurement<T>>
extends TimeStamped, Comparable<ObservedMeasurement<?>> {
public interface ObservedMeasurement<T extends ObservedMeasurement<T>> extends ComparableMeasurement {
/** Enable or disable a measurement.
* <p>
......@@ -101,14 +99,6 @@ public interface ObservedMeasurement<T extends ObservedMeasurement<T>>
*/
double[] getBaseWeight();
/** Get the observed value.
* <p>
* The observed value is the value that was measured by the instrument.
* </p>
* @return observed value (array of size {@link #getDimension()}
*/
double[] getObservedValue();
/** Add a modifier.
* <p>
* The modifiers are applied in the order in which they are added in order to
......@@ -159,49 +149,4 @@ public interface ObservedMeasurement<T extends ObservedMeasurement<T>>
EstimatedMeasurement<T> estimate(int iteration, int evaluation, SpacecraftState[] states)
throws OrekitException;
/** {@inheritDoc}
* <p>
* Measurements comparison is primarily chronological, but measurements
* with the same date are sorted based on the observed value. Even if they
* have the same value too, they will <em>not</em> be considered equal if they
* correspond to different instances. This allows to store measurements in
* {@link java.util.SortedSet SortedSet} without losing any measurements, even
* redundant ones.
* </p>
* @since 9.2
*/
@Override
default int compareTo(final ObservedMeasurement<?> other) {
if (this == other) {
// only case where measurements are considered equal
return 0;
}
int result = getDate().compareTo(other.getDate());
if (result == 0) {
// simultaneous measurements, we compare values
final double[] thisV = getObservedValue();
final double[] otherV = other.getObservedValue();
if (thisV.length > otherV.length) {
result = +1;
} else if (thisV.length < otherV.length) {
result = 1;
} else {
for (int i = 0; i < thisV.length && result == 0; ++i) {
result = Double.compare(thisV[i], otherV[i]);
}
if (result == 0) {
// measurements have the same value,
// but we do not want them to appear as equal
// we set up an arbitrary order
result = -1;
}
}
}
return result;
}
}
......@@ -21,6 +21,10 @@
</properties>
<body>
<release version="9.2" date="TBD" description="TBD">
<action dev="luc" type="fix">
Fixed compilation problems with JDK 1.8
Fixes issue #462.
</action>
<action dev="luc" type="add" >
Added specific attitude mode for GNSS satellites: GPS (block IIA, block IIF, block IIF),
GLONASS, GALILEO, BEIDOU (GEO, IGSO, MEO). This is still considered experimental as there
......
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