diff --git a/core/src/main/java/org/orekit/rugged/api/RuggedMessages.java b/core/src/main/java/org/orekit/rugged/api/RuggedMessages.java index 044571dd9b86d4fbf0a194c7bcaeffdc6abd3c6e..0f63da906b0335009f4fad7e5af68b8f0f4ef440 100644 --- a/core/src/main/java/org/orekit/rugged/api/RuggedMessages.java +++ b/core/src/main/java/org/orekit/rugged/api/RuggedMessages.java @@ -57,6 +57,7 @@ public enum RuggedMessages implements Localizable { UNINITIALIZED_CONTEXT("general context has not been initialized"), EMPTY_TILE("tile is empty: {0} ⨉ {1}"), UNKNOWN_SENSOR("unknown sensor {0}"), + LINE_OF_SIGHT_DOES_NOT_REACH_GROUND("line-of-sight does not reach ground"), LINE_OF_SIGHT_NEVER_CROSSES_LATITUDE("line-of-sight never crosses latitude {0}"), LINE_OF_SIGHT_NEVER_CROSSES_LONGITUDE("line-of-sight never crosses longitude {0}"), LINE_OF_SIGHT_NEVER_CROSSES_ALTITUDE("line-of-sight never crosses altitude {0}"), diff --git a/core/src/main/java/org/orekit/rugged/intersection/duvenhage/DuvenhageAlgorithm.java b/core/src/main/java/org/orekit/rugged/intersection/duvenhage/DuvenhageAlgorithm.java index 9079bc36c0d74dd1dd5a04323b93223f77b3a1a9..2d1b03cdb952da3fecde1b1905ca0d11b4aaa457 100644 --- a/core/src/main/java/org/orekit/rugged/intersection/duvenhage/DuvenhageAlgorithm.java +++ b/core/src/main/java/org/orekit/rugged/intersection/duvenhage/DuvenhageAlgorithm.java @@ -72,6 +72,9 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm { // compute intersection with ellipsoid final GeodeticPoint gp0 = ellipsoid.pointOnGround(position, los); + if (gp0 == null) { + throw new RuggedException(RuggedMessages.LINE_OF_SIGHT_DOES_NOT_REACH_GROUND); + } // locate the entry tile along the line-of-sight MinMaxTreeTile tile = cache.getTile(gp0.getLatitude(), gp0.getLongitude()); diff --git a/core/src/main/resources/assets/org/orekit/rugged/RuggedMessages_en.utf8 b/core/src/main/resources/assets/org/orekit/rugged/RuggedMessages_en.utf8 index 587c7eb1baa279cffde6a495a6917daa637cc78d..118da04a8d37f0a9c650aa6711e6f899732802c0 100644 --- a/core/src/main/resources/assets/org/orekit/rugged/RuggedMessages_en.utf8 +++ b/core/src/main/resources/assets/org/orekit/rugged/RuggedMessages_en.utf8 @@ -19,6 +19,9 @@ EMPTY_TILE = tile is empty: {0} ⨉ {1} # unknown sensor {0} UNKNOWN_SENSOR = unknown sensor {0} +# line-of-sight does not reach ground +LINE_OF_SIGHT_DOES_NOT_REACH_GROUND = line-of-sight does not reach ground + # line-of-sight never crosses latitude {0} LINE_OF_SIGHT_NEVER_CROSSES_LATITUDE = line-of-sight never crosses latitude {0} diff --git a/core/src/main/resources/assets/org/orekit/rugged/RuggedMessages_fr.utf8 b/core/src/main/resources/assets/org/orekit/rugged/RuggedMessages_fr.utf8 index 825795b4dcba86e9ce285976c93e05e64e79c5e6..dbbd3973ec50be29cb9e2470279e4a56b34b7831 100644 --- a/core/src/main/resources/assets/org/orekit/rugged/RuggedMessages_fr.utf8 +++ b/core/src/main/resources/assets/org/orekit/rugged/RuggedMessages_fr.utf8 @@ -19,6 +19,9 @@ EMPTY_TILE = la tuile est vide : {0} ⨉ {1} # unknown sensor {0} UNKNOWN_SENSOR = capteur {0} inconnu +# line-of-sight does not reach ground +LINE_OF_SIGHT_DOES_NOT_REACH_GROUND = la ligne de visée n''atteint pas le sol + # line-of-sight never crosses latitude {0} LINE_OF_SIGHT_NEVER_CROSSES_LATITUDE = la ligne de visée ne franchit jamais la latitude {0} diff --git a/core/src/test/java/org/orekit/rugged/api/RuggedMessagesTest.java b/core/src/test/java/org/orekit/rugged/api/RuggedMessagesTest.java index abde2c084c32ffdd4b53e80a323426902e43971d..9b7d06081d59da6d8361c24a531878951235b7cf 100644 --- a/core/src/test/java/org/orekit/rugged/api/RuggedMessagesTest.java +++ b/core/src/test/java/org/orekit/rugged/api/RuggedMessagesTest.java @@ -29,7 +29,7 @@ public class RuggedMessagesTest { @Test public void testMessageNumber() { - Assert.assertEquals(13, RuggedMessages.values().length); + Assert.assertEquals(14, RuggedMessages.values().length); } @Test diff --git a/core/src/test/java/org/orekit/rugged/intersection/duvenhage/DuvenhageAlgorithmTest.java b/core/src/test/java/org/orekit/rugged/intersection/duvenhage/DuvenhageAlgorithmTest.java index 8c5bc03b4d75610d1896fb26ea52a20fed472b35..ce1e1f9c74c53b606fb4ade18013dd92cd074860 100644 --- a/core/src/test/java/org/orekit/rugged/intersection/duvenhage/DuvenhageAlgorithmTest.java +++ b/core/src/test/java/org/orekit/rugged/intersection/duvenhage/DuvenhageAlgorithmTest.java @@ -18,10 +18,12 @@ package org.orekit.rugged.intersection.duvenhage; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.junit.Assert; import org.junit.Test; import org.orekit.bodies.GeodeticPoint; import org.orekit.errors.OrekitException; import org.orekit.rugged.api.RuggedException; +import org.orekit.rugged.api.RuggedMessages; import org.orekit.rugged.intersection.AbstractAlgorithmTest; import org.orekit.rugged.intersection.IntersectionAlgorithm; import org.orekit.rugged.intersection.duvenhage.DuvenhageAlgorithm; @@ -55,4 +57,18 @@ public class DuvenhageAlgorithmTest extends AbstractAlgorithmTest { checkIntersection(position, los, intersection); } + @Test + public void testWrongPositionMissesGround() throws RuggedException, OrekitException { + setUpMayonVolcanoContext(); + final IntersectionAlgorithm algorithm = createAlgorithm(updater, 8); + Vector3D position = new Vector3D(7.551889113912788E9, -3.173692685491814E10, 1.5727517321541348E9); + Vector3D los = new Vector3D(0.010401349221417867, -0.17836068905951286, 0.9839101973923178); + try { + algorithm.intersection(earth, position, los); + Assert.fail("an exception should have been thrown"); + } catch (RuggedException re) { + Assert.assertEquals(RuggedMessages.LINE_OF_SIGHT_DOES_NOT_REACH_GROUND, re.getSpecifier()); + } + } + } diff --git a/src/site/xdoc/changes.xml b/src/site/xdoc/changes.xml index 2751dc151d5072dfec39c171d295649752397994..1c42211de3f9d700b20ad53bdd6c6b0cd476bb94 100644 --- a/src/site/xdoc/changes.xml +++ b/src/site/xdoc/changes.xml @@ -22,6 +22,9 @@ <body> <release version="1.0" date="TBD" description="TBD"> + <action dev="luc" type="fix"> + Added detection of wrong position/line-of-sight that misses the ground. + </action> <action dev="luc" type="add"> Added a way to reuse transform interpolator from one run to another by dumping its state into a file, thus avoiding costly initialization.