From f534a214c295cc0c1cfef1da8f6adb67e31ad838 Mon Sep 17 00:00:00 2001
From: Luc Maisonobe <luc@orekit.org>
Date: Wed, 12 Mar 2014 20:21:04 +0100
Subject: [PATCH] Intersection algorithms can use the new ExtendedEllipsoid.

This allows them to chop off line-of-sight at DEM cells boundaries.
---
 .../rugged/core/IgnoreDEMAlgorithm.java       | 59 +++++++++++++++++++
 .../core/dem/IntersectionAlgorithm.java       | 16 ++---
 .../core/duvenhage/DuvenhageAlgorithm.java    |  8 ++-
 3 files changed, 73 insertions(+), 10 deletions(-)
 create mode 100644 rugged-core/src/main/java/org/orekit/rugged/core/IgnoreDEMAlgorithm.java

diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/IgnoreDEMAlgorithm.java b/rugged-core/src/main/java/org/orekit/rugged/core/IgnoreDEMAlgorithm.java
new file mode 100644
index 00000000..a17d742b
--- /dev/null
+++ b/rugged-core/src/main/java/org/orekit/rugged/core/IgnoreDEMAlgorithm.java
@@ -0,0 +1,59 @@
+/* Copyright 2013-2014 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.rugged.core;
+
+import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
+import org.orekit.bodies.GeodeticPoint;
+import org.orekit.errors.OrekitException;
+import org.orekit.rugged.api.RuggedException;
+import org.orekit.rugged.api.TileUpdater;
+import org.orekit.rugged.core.dem.IntersectionAlgorithm;
+
+/** Intersection ignoring Digital Elevation Model.
+ * <p>
+ * This dummy implementation simply uses the ellipsoid itself.
+ * </p>
+ * @author Luc Maisonobe
+ */
+public class IgnoreDEMAlgorithm implements IntersectionAlgorithm {
+
+    /** Simple constructor.
+     */
+    public IgnoreDEMAlgorithm() {
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setUpTilesManagement(final TileUpdater updater, final int maxCachedTiles) {
+        // we ignore the DEM
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public GeodeticPoint intersection(final ExtendedEllipsoid ellipsoid,
+                                      final Vector3D position, final Vector3D los)
+        throws RuggedException {
+        try {
+            return ellipsoid.transform(ellipsoid.pointAtAltitude(position, los, 0.0),
+                                       ellipsoid.getBodyFrame(), null);
+        } catch (OrekitException oe) {
+            // this should never happen
+            throw new RuggedException(oe, oe.getSpecifier(), oe.getParts());
+        }
+    }
+
+}
diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/dem/IntersectionAlgorithm.java b/rugged-core/src/main/java/org/orekit/rugged/core/dem/IntersectionAlgorithm.java
index d50fc051..7eed2dba 100644
--- a/rugged-core/src/main/java/org/orekit/rugged/core/dem/IntersectionAlgorithm.java
+++ b/rugged-core/src/main/java/org/orekit/rugged/core/dem/IntersectionAlgorithm.java
@@ -18,10 +18,11 @@ package org.orekit.rugged.core.dem;
 
 import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
 import org.orekit.bodies.GeodeticPoint;
-import org.orekit.rugged.api.GroundPoint;
+import org.orekit.rugged.api.RuggedException;
 import org.orekit.rugged.api.TileUpdater;
+import org.orekit.rugged.core.ExtendedEllipsoid;
 
-/** Interface for Digital Elevation Model algorithm.
+/** Interface for Digital Elevation Model intersection algorithm.
  * @author Luc Maisonobe
  */
 public interface IntersectionAlgorithm {
@@ -33,12 +34,13 @@ public interface IntersectionAlgorithm {
     void setUpTilesManagement(TileUpdater updater, int maxCachedTiles);
 
     /** Compute intersection of line with Digital Elevation Model.
-     * @param latitude latitude of line arrival at zero altitude
-     * @param longitude longitude of line arrival at zero altitude
-     * @param direction arrival direction in (East, North, Zenith) frame
-     * (the direction is from spacecraft to ground)
+     * @param ellipsoid reference ellipsoid
+     * @param position pixel position in ellipsoid frame
+     * @param los pixel line-of-sight in ellipsoid frame
      * @return point at which the line first enters ground
+     * @exception RuggedException if intersection cannot be found
      */
-    GroundPoint intersection(double latitude0, double longitude0, Vector3D direction);
+    GeodeticPoint intersection(ExtendedEllipsoid ellipsoid, Vector3D position, Vector3D los)
+        throws RuggedException;
 
 }
diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java
index 102dd9b3..6713007a 100644
--- a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java
+++ b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java
@@ -17,12 +17,13 @@
 package org.orekit.rugged.core.duvenhage;
 
 import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
-import org.orekit.rugged.api.GroundPoint;
+import org.orekit.bodies.GeodeticPoint;
 import org.orekit.rugged.api.TileUpdater;
+import org.orekit.rugged.core.ExtendedEllipsoid;
 import org.orekit.rugged.core.dem.IntersectionAlgorithm;
 import org.orekit.rugged.core.dem.TilesCache;
 
-/** Direct and inverse localization using Duvenhage's algorithm.
+/** Digital Elevation Model intersection using Duvenhage's algorithm.
  * <p>
  * The algorithm is described in the 2009 paper:
  * <a href="http://researchspace.csir.co.za/dspace/bitstream/10204/3041/1/Duvenhage_2009.pdf">Using
@@ -49,7 +50,8 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm {
 
     /** {@inheritDoc} */
     @Override
-    public GroundPoint intersection(final double latitude0, final double longitude0, final Vector3D direction) {
+    public GeodeticPoint intersection(final ExtendedEllipsoid ellipsoid,
+                                      final Vector3D position, final Vector3D los) {
         // TODO: compute intersection
         return null;
     }
-- 
GitLab