diff --git a/src/main/java/org/orekit/rugged/api/Rugged.java b/src/main/java/org/orekit/rugged/api/Rugged.java index 7801ec9f83f21d1adc07f929b04c464b812de3f3..db7fa8bd19cc6c81fd4fe8ccad2fa8be14fe5822 100644 --- a/src/main/java/org/orekit/rugged/api/Rugged.java +++ b/src/main/java/org/orekit/rugged/api/Rugged.java @@ -550,20 +550,43 @@ public class Rugged { } /** Inverse localization of a ground point. + * <p> + * The point is given only by its latitude and longitude, the elevation is + * computed from the Digital Elevation Model. + * </p> * @param sensorName name of the line sensor - * @param groundPoint ground point to localize + * @param latitude ground point latitude + * @param longitude ground point longitude * @param minLine minimum line number * @param maxLine maximum line number * @return sensor pixel seeing ground point, or null if ground point cannot * be seen between the prescribed line numbers * @exception RuggedException if line cannot be localized, or sensor is unknown */ - public SensorPixel inverseLocalization(final String sensorName, final GeodeticPoint groundPoint, + public SensorPixel inverseLocalization(final String sensorName, + final double latitude, final double longitude, + final double minLine, final double maxLine) + throws RuggedException { + final GeodeticPoint groundPoint = + new GeodeticPoint(latitude, longitude, algorithm.getElevation(latitude, longitude)); + return inverseLocalization(sensorName, groundPoint, minLine, maxLine); + } + + /** Inverse localization of a point. + * @param sensorName name of the line sensor + * @param point point to localize + * @param minLine minimum line number + * @param maxLine maximum line number + * @return sensor pixel seeing point, or null if point cannot be seen between the + * prescribed line numbers + * @exception RuggedException if line cannot be localized, or sensor is unknown + */ + public SensorPixel inverseLocalization(final String sensorName, final GeodeticPoint point, final double minLine, final double maxLine) throws RuggedException { final LineSensor sensor = getLineSensor(sensorName); - final Vector3D target = ellipsoid.transform(groundPoint); + final Vector3D target = ellipsoid.transform(point); // find approximately the sensor line at which ground point crosses sensor mean plane final SensorMeanPlaneCrossing planeCrossing = diff --git a/src/main/java/org/orekit/rugged/core/BasicScanAlgorithm.java b/src/main/java/org/orekit/rugged/core/BasicScanAlgorithm.java index 4ed3992f2e311ee4059bbcb7dbfe1bab5c9b152e..7feea66387d19a93605bd1552c963678f27f809a 100644 --- a/src/main/java/org/orekit/rugged/core/BasicScanAlgorithm.java +++ b/src/main/java/org/orekit/rugged/core/BasicScanAlgorithm.java @@ -166,6 +166,14 @@ public class BasicScanAlgorithm implements IntersectionAlgorithm { } } + /** {@inheritDoc} */ + @Override + public double getElevation(final double latitude, final double longitude) + throws RuggedException { + final Tile tile = cache.getTile(latitude, longitude); + return tile.interpolateElevation(latitude, longitude); + } + /** Check the overall min and max altitudes. * @param tiles tiles to check * @return true if the tile changed either min or max altitude diff --git a/src/main/java/org/orekit/rugged/core/IgnoreDEMAlgorithm.java b/src/main/java/org/orekit/rugged/core/IgnoreDEMAlgorithm.java index 3f72cf41b9efa872ae14c8ff04a974dcb7197aca..9eef0a66418a944dced02ff9de82f82ad171bdc0 100644 --- a/src/main/java/org/orekit/rugged/core/IgnoreDEMAlgorithm.java +++ b/src/main/java/org/orekit/rugged/core/IgnoreDEMAlgorithm.java @@ -57,4 +57,15 @@ public class IgnoreDEMAlgorithm implements IntersectionAlgorithm { return intersection(ellipsoid, position, los); } + /** {@inheritDoc} + * <p> + * As this algorithm ignored the Digital Elevation Model, + * this method always returns 0.0. + * </p> + */ + @Override + public double getElevation(final double latitude, final double longitude) { + return 0.0; + } + } diff --git a/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java b/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java index 8b9f3097fc50a39e0cf9373eddecef3e4333beeb..6bfd8992b21623aea95be6ad370592338e93f62f 100644 --- a/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java +++ b/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java @@ -178,6 +178,14 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm { } } + /** {@inheritDoc} */ + @Override + public double getElevation(final double latitude, final double longitude) + throws RuggedException { + final Tile tile = cache.getTile(latitude, longitude); + return tile.interpolateElevation(latitude, longitude); + } + /** Compute intersection of line with Digital Elevation Model in a sub-tile. * @param depth recursion depth * @param ellipsoid reference ellipsoid diff --git a/src/main/java/org/orekit/rugged/core/raster/IntersectionAlgorithm.java b/src/main/java/org/orekit/rugged/core/raster/IntersectionAlgorithm.java index bf8ac897e970b516f1bd7b076f9121c5fcc72b5f..1bbd8d571149888162b953f439dd0a1ff9dd14a8 100644 --- a/src/main/java/org/orekit/rugged/core/raster/IntersectionAlgorithm.java +++ b/src/main/java/org/orekit/rugged/core/raster/IntersectionAlgorithm.java @@ -55,4 +55,13 @@ public interface IntersectionAlgorithm { GeodeticPoint closeGuess) throws RuggedException; + /** Get elevation at a given ground point. + * @param latitude ground point latitude + * @param longitude ground point longitude + * @return elevation at specified point + * @exception RuggedException if Digital Elevation Model does not cover point + */ + double getElevation(double latitude, double longitude) + throws RuggedException; + } diff --git a/src/test/java/org/orekit/rugged/api/RuggedTest.java b/src/test/java/org/orekit/rugged/api/RuggedTest.java index c1bd9133ef4460f65b40f81a00d414b0a2026eaf..e53d7e30fdd332a31a2f0d0ced6d7820939416ae 100644 --- a/src/test/java/org/orekit/rugged/api/RuggedTest.java +++ b/src/test/java/org/orekit/rugged/api/RuggedTest.java @@ -476,8 +476,6 @@ public class RuggedTest { double lat0 = FastMath.toRadians(-22.9); double lon0 = FastMath.toRadians(142.4); double delta = FastMath.toRadians(0.5); - Tile tile = new SimpleTileFactory().createTile(); - updater.updateTile(lat0, lon0, tile); try { int size = dimension * dimension * 2 * Integer.SIZE / 8; @@ -491,9 +489,7 @@ public class RuggedTest { double latitude = lat0 + (i * delta) / dimension; for (int j = 0; j < dimension; ++j) { double longitude = lon0 + (j * delta) / dimension; - GeodeticPoint gp = new GeodeticPoint(latitude, longitude, - tile.interpolateElevation(latitude, longitude)); - SensorPixel sp = rugged.inverseLocalization("line", gp, 0, dimension); + SensorPixel sp = rugged.inverseLocalization("line", latitude, longitude, 0, dimension); if (sp == null) { ++badPixels; buffer.putInt(-1);