diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/dem/SimpleTile.java b/rugged-core/src/main/java/org/orekit/rugged/core/dem/SimpleTile.java index 38d79301d7b792a8c909b042595f29a7d2faca7a..9503e0b17f152b285df21cddfbe6a97dd86448c3 100644 --- a/rugged-core/src/main/java/org/orekit/rugged/core/dem/SimpleTile.java +++ b/rugged-core/src/main/java/org/orekit/rugged/core/dem/SimpleTile.java @@ -188,8 +188,8 @@ public class SimpleTile implements Tile { public double interpolateElevation(double latitude, double longitude) throws RuggedException { - final double doubleLatitudeIndex = getLatitudeIndex(latitude); - final double doubleLongitudeIndex = getLontitudeIndex(longitude); + final double doubleLatitudeIndex = getDoubleLatitudeIndex(latitude); + final double doubleLongitudeIndex = getDoubleLontitudeIndex(longitude); final int latitudeIndex = (int) FastMath.floor(doubleLatitudeIndex); final int longitudeIndex = (int) FastMath.floor(doubleLongitudeIndex); if (latitudeIndex < 0 || latitudeIndex >= (latitudeRows - 2) || diff --git a/rugged-core/src/test/java/org/orekit/rugged/core/dem/SimpleTileTest.java b/rugged-core/src/test/java/org/orekit/rugged/core/dem/SimpleTileTest.java index a2ce7df9ddef4453f6d14acc06a07c666dc13a96..2e5844f1527b436dd055790c93208d58c2f00a3a 100644 --- a/rugged-core/src/test/java/org/orekit/rugged/core/dem/SimpleTileTest.java +++ b/rugged-core/src/test/java/org/orekit/rugged/core/dem/SimpleTileTest.java @@ -94,6 +94,19 @@ public class SimpleTileTest { } + @Test + public void testInterpolation() throws RuggedException { + SimpleTile tile = new SimpleTileFactory().createTile(); + tile.setGeometry(0.0, 0.0, 1.0, 1.0, 50, 50); + tile.setElevation(20, 14, 91.0); + tile.setElevation(20, 15, 210.0); + tile.setElevation(21, 14, 162.0); + tile.setElevation(21, 15, 95.0); + Assert.assertEquals(150.5, tile.interpolateElevation(20.0, 14.5), 1.0e-10); + Assert.assertEquals(128.5, tile.interpolateElevation(21.0, 14.5), 1.0e-10); + Assert.assertEquals(146.1, tile.interpolateElevation(20.2, 14.5), 1.0e-10); + } + @Test public void testOutOfBounds() throws RuggedException {