From eee5384206e7f0c0b0347cf8fd036acce925bee7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Jonglez?= <clement@jonglez.space>
Date: Thu, 23 May 2024 11:11:32 +0200
Subject: [PATCH] =?UTF-8?q?add=20valueSpanMapChanged=E2=80=8B=20method=20a?=
 =?UTF-8?q?dded=20to=20ParameterObserver=20in=20Orekit=2012?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../java/org/orekit/rugged/los/FixedRotation.java     | 11 ++++++++++-
 .../java/org/orekit/rugged/los/FixedZHomothety.java   | 11 ++++++++++-
 src/main/java/org/orekit/rugged/los/LOSBuilder.java   |  9 ++++++++-
 .../org/orekit/rugged/los/PolynomialRotation.java     | 11 ++++++++++-
 4 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/orekit/rugged/los/FixedRotation.java b/src/main/java/org/orekit/rugged/los/FixedRotation.java
index 5b416136..0305aefc 100644
--- a/src/main/java/org/orekit/rugged/los/FixedRotation.java
+++ b/src/main/java/org/orekit/rugged/los/FixedRotation.java
@@ -26,8 +26,10 @@ import org.hipparchus.geometry.euclidean.threed.RotationConvention;
 import org.hipparchus.geometry.euclidean.threed.Vector3D;
 import org.hipparchus.util.FastMath;
 import org.orekit.rugged.utils.DerivativeGenerator;
+import org.orekit.time.AbsoluteDate;
 import org.orekit.utils.ParameterDriver;
 import org.orekit.utils.ParameterObserver;
+import org.orekit.utils.TimeSpanMap;
 
 /** {@link TimeIndependentLOSTransform LOS transform} based on a fixed rotation.
  * @author Luc Maisonobe
@@ -71,7 +73,14 @@ public class FixedRotation implements TimeIndependentLOSTransform {
         this.angleDriver = new ParameterDriver(name, angle, SCALE, -2 * FastMath.PI, 2 * FastMath.PI);
         angleDriver.addObserver(new ParameterObserver() {
             @Override
-            public void valueChanged(final double previousValue, final ParameterDriver driver) {
+            public void valueChanged(final double previousValue, final ParameterDriver driver, AbsoluteDate date) {
+                // reset rotations to null, they will be evaluated lazily if needed
+                rotation = null;
+                rDS      = null;
+            }
+            
+            @Override
+            public void valueSpanMapChanged​(TimeSpanMap<Double> previousValueSpanMap, ParameterDriver driver) {
                 // reset rotations to null, they will be evaluated lazily if needed
                 rotation = null;
                 rDS      = null;
diff --git a/src/main/java/org/orekit/rugged/los/FixedZHomothety.java b/src/main/java/org/orekit/rugged/los/FixedZHomothety.java
index f1f5c33b..a171e873 100644
--- a/src/main/java/org/orekit/rugged/los/FixedZHomothety.java
+++ b/src/main/java/org/orekit/rugged/los/FixedZHomothety.java
@@ -23,8 +23,10 @@ import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
 import org.hipparchus.geometry.euclidean.threed.Vector3D;
 import org.hipparchus.util.FastMath;
 import org.orekit.rugged.utils.DerivativeGenerator;
+import org.orekit.time.AbsoluteDate;
 import org.orekit.utils.ParameterDriver;
 import org.orekit.utils.ParameterObserver;
+import org.orekit.utils.TimeSpanMap;
 
 /** {@link TimeIndependentLOSTransform LOS transform} based on a homothety along the Z axis.
  * @author Lucie Labatallee
@@ -65,7 +67,14 @@ public class FixedZHomothety implements TimeIndependentLOSTransform {
         this.factorDriver = new ParameterDriver(name, factorvalue, SCALE, 0, Double.POSITIVE_INFINITY);
         factorDriver.addObserver(new ParameterObserver() {
             @Override
-            public void valueChanged(final double previousValue, final ParameterDriver driver) {
+            public void valueChanged(final double previousValue, final ParameterDriver driver, AbsoluteDate date) {
+                // reset factor to zero, they will be evaluated lazily if needed
+                factor = 0.0;
+                factorDS = null;
+            }
+            
+            @Override
+            public void valueSpanMapChanged​(TimeSpanMap<Double> previousValueSpanMap, ParameterDriver driver) {
                 // reset factor to zero, they will be evaluated lazily if needed
                 factor = 0.0;
                 factorDS = null;
diff --git a/src/main/java/org/orekit/rugged/los/LOSBuilder.java b/src/main/java/org/orekit/rugged/los/LOSBuilder.java
index 3bc88855..583bc60a 100644
--- a/src/main/java/org/orekit/rugged/los/LOSBuilder.java
+++ b/src/main/java/org/orekit/rugged/los/LOSBuilder.java
@@ -28,6 +28,7 @@ import org.orekit.rugged.utils.DerivativeGenerator;
 import org.orekit.time.AbsoluteDate;
 import org.orekit.utils.ParameterDriver;
 import org.orekit.utils.ParameterObserver;
+import org.orekit.utils.TimeSpanMap;
 
 /** Builder for lines-of-sight list.
  * <p>
@@ -226,7 +227,13 @@ public class LOSBuilder {
             final ParameterObserver resettingObserver = new ParameterObserver() {
                 /** {@inheritDoc} */
                 @Override
-                public void valueChanged(final double previousValue, final ParameterDriver driver) {
+                public void valueChanged(final double previousValue, final ParameterDriver driver, AbsoluteDate date) {
+                    Arrays.fill(transformed, null);
+                }
+                
+                /** {@inheritDoc} */
+                @Override
+                public void valueSpanMapChanged​(TimeSpanMap<Double> previousValueSpanMap, ParameterDriver driver) {
                     Arrays.fill(transformed, null);
                 }
             };
diff --git a/src/main/java/org/orekit/rugged/los/PolynomialRotation.java b/src/main/java/org/orekit/rugged/los/PolynomialRotation.java
index 63e3082a..79e1e99a 100644
--- a/src/main/java/org/orekit/rugged/los/PolynomialRotation.java
+++ b/src/main/java/org/orekit/rugged/los/PolynomialRotation.java
@@ -32,6 +32,7 @@ import org.orekit.rugged.utils.DerivativeGenerator;
 import org.orekit.time.AbsoluteDate;
 import org.orekit.utils.ParameterDriver;
 import org.orekit.utils.ParameterObserver;
+import org.orekit.utils.TimeSpanMap;
 
 /** {@link LOSTransform LOS transform} based on a rotation with polynomial angle.
  * @author Luc Maisonobe
@@ -87,7 +88,15 @@ public class PolynomialRotation implements LOSTransform {
         this.coefficientsDrivers = new ParameterDriver[angleCoeffs.length];
         final ParameterObserver resettingObserver = new ParameterObserver() {
             @Override
-            public void valueChanged(final double previousValue, final ParameterDriver driver) {
+            public void valueChanged(final double previousValue, final ParameterDriver driver, AbsoluteDate date) {
+                // reset rotations to null, they will be evaluated lazily if needed
+                angle   = null;
+                axisDS  = null;
+                angleDS = null;
+            }
+            
+            @Override
+            public void valueSpanMapChanged​(TimeSpanMap<Double> previousValueSpanMap, ParameterDriver driver) {
                 // reset rotations to null, they will be evaluated lazily if needed
                 angle   = null;
                 axisDS  = null;
-- 
GitLab