Commit 3daf04c7 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Merge branch 'transitions-span-link' into issue-833

parents 249159f4 4c2ca10f
......@@ -21,6 +21,12 @@
</properties>
<body>
<release version="11.1" date="TBD" description="TBD">
<action dev="luc" type="fix" issue="884">
Deprecated TimeSpanMap.getTransitions()
</action>
<action dev="luc" type="fix" issue="885">
Allow to enter the same transition date in TimeSpanMap several times
</action>
<action dev="luc" type="fix" issue="833">
Added a way to erase all earlier/later transitions when adding an entry
to a TimeSpanMap.
......
......@@ -383,7 +383,7 @@ public class AttitudesSequence implements AttitudeProvider {
// reset the transition parameters (this will be done once for each switch,
// despite doing it only once would have sufficient; its not really a problem)
forward = t.durationFrom(s0.getDate()) >= 0.0;
if (activated.getTransitions().size() > 1) {
if (activated.getSpansNumber() > 1) {
// remove transitions that will be overridden during upcoming propagation
if (forward) {
activated = activated.extractRange(AbsoluteDate.PAST_INFINITY, s0.getDate().shiftedBy(transitionTime));
......
......@@ -239,7 +239,7 @@ public class SinexLoader {
final Station station = getStation(parseString(line, 1, 4));
// check if it is the first eccentricity entry for this station
if (station.getEccentricitiesTimeSpanMap().getTransitions().size() == 1) {
if (station.getEccentricitiesTimeSpanMap().getSpansNumber() == 1) {
// we are parsing eccentricity data for a new station
firstEcc = true;
}
......
......@@ -118,7 +118,7 @@ public class Station {
*/
public AbsoluteDate getValidFrom() {
if (validFrom == null) {
validFrom = eccentricitiesTimeSpanMap.getTransitions().first().getDate();
validFrom = eccentricitiesTimeSpanMap.getFirstTransition().getDate();
}
return validFrom;
}
......@@ -137,7 +137,7 @@ public class Station {
*/
public AbsoluteDate getValidUntil() {
if (validUntil == null) {
validUntil = eccentricitiesTimeSpanMap.getTransitions().last().getDate();
validUntil = eccentricitiesTimeSpanMap.getLastTransition().getDate();
}
return validUntil;
}
......
......@@ -21,8 +21,8 @@ import java.util.List;
import java.util.NavigableSet;
import java.util.stream.Stream;
import org.hipparchus.Field;
import org.hipparchus.CalculusFieldElement;
import org.hipparchus.Field;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.analysis.differentiation.Gradient;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
......@@ -232,11 +232,21 @@ public class TimeSpanDragForce extends AbstractDragForceModel {
/** Get the {@link Transition}s of the drag sensitive time span map.
* @return the {@link Transition}s for the drag sensitive time span map
* @deprecated as of 11.1, replaced by {@link #getFirstSpan()}
*/
@Deprecated
public NavigableSet<Transition<DragSensitive>> getTransitions() {
return dragSensitiveTimeSpanMap.getTransitions();
}
/** Get the first {@link Span time span} of the drag sensitive time span map.
* @return the first {@link Span time span} of the drag sensitive time span map
* @since 11.1
*/
public Span<DragSensitive> getFirstSpan() {
return dragSensitiveTimeSpanMap.getFirstSpan();
}
/** {@inheritDoc} */
@Override
public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {
......@@ -362,25 +372,17 @@ public class TimeSpanDragForce extends AbstractDragForceModel {
// Get all transitions from the TimeSpanMap
final List<ParameterDriver> listParameterDrivers = new ArrayList<>();
final NavigableSet<Transition<DragSensitive>> dragSensitiveTransitions = getTransitions();
// Loop on the transitions
for (Transition<DragSensitive> transition : dragSensitiveTransitions) {
// Add all the "before" parameter drivers of each transition
for (ParameterDriver driver : transition.getBefore().getDragParametersDrivers()) {
// Loop on the spans
for (Span<DragSensitive> span = getFirstSpan(); span != null; span = span.next()) {
// Add all the parameter drivers of the span
for (ParameterDriver driver : span.getData().getDragParametersDrivers()) {
// Add the driver only if the name does not exist already
if (!findByName(listParameterDrivers, driver.getName())) {
listParameterDrivers.add(driver);
}
}
}
// Finally, add the "after" parameter drivers of the last transition
for (ParameterDriver driver : dragSensitiveTransitions.last().getAfter().getDragParametersDrivers()) {
// Adds only if the name does not exist already
if (!findByName(listParameterDrivers, driver.getName())) {
listParameterDrivers.add(driver);
}
}
// Return an array of parameter drivers with no duplicated name
return listParameterDrivers;
......@@ -464,10 +466,9 @@ public class TimeSpanDragForce extends AbstractDragForceModel {
// Get all transitions
final List<AbsoluteDate> listDates = new ArrayList<>();
final NavigableSet<Transition<DragSensitive>> dragSensitiveTransitions = getTransitions();
// Extract all the transitions' dates
for (Transition<DragSensitive> transition : dragSensitiveTransitions) {
for (Transition<DragSensitive> transition = getFirstSpan().getEndTransition(); transition != null; transition = transition.next()) {
listDates.add(transition.getDate());
}
// Return the array of transition dates
......
......@@ -221,11 +221,21 @@ public class TimeSpanParametricAcceleration extends AbstractForceModel {
/** Get the {@link Transition}s of the acceleration model time span map.
* @return the {@link Transition}s for the acceleration model time span map
* @deprecated as of 11.1, replace by {@link #getFirstSpan()}
*/
@Deprecated
public NavigableSet<Transition<AccelerationModel>> getTransitions() {
return accelerationModelTimeSpanMap.getTransitions();
}
/** Get the first {@link Span time span} of the acceleration model time span map.
* @return the first {@link Span time span} of the acceleration model time span map
* @since 11.1
*/
public Span<AccelerationModel> getFirstSpan() {
return accelerationModelTimeSpanMap.getFirstSpan();
}
/** {@inheritDoc} */
@Override
public boolean dependsOnPositionOnly() {
......@@ -321,12 +331,11 @@ public class TimeSpanParametricAcceleration extends AbstractForceModel {
// Get all transitions from the TimeSpanMap
final List<ParameterDriver> listParameterDrivers = new ArrayList<>();
final NavigableSet<Transition<AccelerationModel>> accelerationModelTransitions = getTransitions();
// Loop on the transitions
for (Transition<AccelerationModel> transition : accelerationModelTransitions) {
// Add all the "before" parameter drivers of each transition
for (ParameterDriver driver : transition.getBefore().getParametersDrivers()) {
// Loop on the spans
for (Span<AccelerationModel> span = getFirstSpan(); span != null; span = span.next()) {
// Add all the parameter drivers of the time span
for (ParameterDriver driver : span.getData().getParametersDrivers()) {
// Add the driver only if the name does not exist already
if (!findByName(listParameterDrivers, driver.getName())) {
listParameterDrivers.add(driver);
......@@ -334,14 +343,6 @@ public class TimeSpanParametricAcceleration extends AbstractForceModel {
}
}
// Finally, add the "after" parameter drivers of the last transition
for (ParameterDriver driver : accelerationModelTransitions.last().getAfter().getParametersDrivers()) {
// Adds only if the name does not exist already
if (!findByName(listParameterDrivers, driver.getName())) {
listParameterDrivers.add(driver);
}
}
// Return an array of parameter drivers with no duplicated name
return Collections.unmodifiableList(listParameterDrivers);
......
......@@ -133,7 +133,7 @@ public class AntexLoader {
satellitesAntennas.
stream().
filter(m -> {
final SatelliteAntenna first = m.getTransitions().first().getBefore();
final SatelliteAntenna first = m.getFirstSpan().getData();
return first.getSatelliteSystem() == satelliteSystem &&
first.getPrnNumber() == prnNumber;
}).findFirst();
......
......@@ -570,7 +570,7 @@ public class RinexClock {
public void addReferenceClockList(final List<ReferenceClock> referenceClockList,
final AbsoluteDate startDate) {
if (referenceClocks == null) {
referenceClocks = new TimeSpanMap<List<ReferenceClock>>(referenceClockList);
referenceClocks = new TimeSpanMap<>(null);
}
referenceClocks.addValidAfter(referenceClockList, startDate, false);
}
......
......@@ -31,6 +31,7 @@ import org.orekit.time.TimeScale;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.ParameterDriver;
import org.orekit.utils.TimeSpanMap;
import org.orekit.utils.TimeSpanMap.Span;
import org.orekit.utils.TimeSpanMap.Transition;
/**
......@@ -89,25 +90,17 @@ public class TimeSpanEstimatedTroposphericModel implements DiscreteTroposphericM
// Get all transitions from the TimeSpanMap
final List<ParameterDriver> listTroposphericParameterDrivers = new ArrayList<>();
final NavigableSet<Transition<EstimatedTroposphericModel>> troposphericModelTransitions = getTransitions();
// Loop on the transitions
for (Transition<EstimatedTroposphericModel> transition : troposphericModelTransitions) {
// Add all the "before" parameter drivers of each transition
for (ParameterDriver tropoDriver : transition.getBefore().getParametersDrivers()) {
// Loop on the spans
for (Span<EstimatedTroposphericModel> span = getFirstSpan(); span != null; span = span.next()) {
// Add all the parameter drivers of each span
for (ParameterDriver tropoDriver : span.getData().getParametersDrivers()) {
// Add the driver only if the name does not exist already
if (!findByName(listTroposphericParameterDrivers, tropoDriver.getName())) {
listTroposphericParameterDrivers.add(tropoDriver);
}
}
}
// Finally, add the "after" parameter drivers of the last transition
for (ParameterDriver tropoDriver : troposphericModelTransitions.last().getAfter().getParametersDrivers()) {
// Adds only if the name does not exist already
if (!findByName(listTroposphericParameterDrivers, tropoDriver.getName())) {
listTroposphericParameterDrivers.add(tropoDriver);
}
}
// Return an array of parameter drivers with no duplicated name
return listTroposphericParameterDrivers;
......@@ -152,11 +145,21 @@ public class TimeSpanEstimatedTroposphericModel implements DiscreteTroposphericM
/** Get the {@link Transition}s of the tropospheric model time span map.
* @return the {@link Transition}s for the tropospheric model time span map
* @deprecated as of 11.1, replaced by {@link #getFirstSpan()}
*/
@Deprecated
public NavigableSet<Transition<EstimatedTroposphericModel>> getTransitions() {
return troposphericModelMap.getTransitions();
}
/** Get the first {@link Span time span} of the tropospheric model time span map.
* @return the first {@link Span time span} of the tropospheric model time span map
* @since 11.1
*/
public Span<EstimatedTroposphericModel> getFirstSpan() {
return troposphericModelMap.getFirstSpan();
}
/** Extract the proper parameter drivers' values from the array in input of the
* {@link #pathDelay(double, GeodeticPoint, double[], AbsoluteDate) pathDelay} method.
* Parameters are filtered given an input date.
......
......@@ -666,14 +666,14 @@ public class ClockFileParserTest {
// Theorical time scale
final TimeScale gps = TimeScalesFactory.getGPS();
// First reference clock theorical values
// First reference clock theoretical values
final String referenceName1 = "USNO";
final String clockId1 = "40451S003";
final double clockConstraint1 = -.123456789012E+00;
final AbsoluteDate startDate1 = new AbsoluteDate(1994, 7, 14, 0, 0, 0.0, gps);
final AbsoluteDate endDate1 = new AbsoluteDate(1994, 7, 14, 20, 59, 0.0, gps);
// Second reference clock theorical values
// Second reference clock theoretical values
final String referenceName2 = "TIDB";
final String clockId2 = "50103M108";
final double clockConstraint2 = -0.123456789012E+00;
......@@ -681,7 +681,7 @@ public class ClockFileParserTest {
final AbsoluteDate endDate2 = new AbsoluteDate(1994, 7, 14, 21, 59, 0.0, gps);
// Check number of time spans
Assert.assertEquals(1, referenceClocksMap.getTransitions().size());
Assert.assertEquals(3, referenceClocksMap.getSpansNumber());
// Get the two lists of reference clocks
final List<ReferenceClock> referenceClocks1 = referenceClocksMap.get(new AbsoluteDate(1994, 7, 14, 15, 0, 0.0, gps));
......
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