From d993d4cb53ffc641cb45eefb1bbe4277c949017d Mon Sep 17 00:00:00 2001 From: Luc Maisonobe <luc@orekit.org> Date: Sat, 15 Mar 2014 10:15:40 +0100 Subject: [PATCH] Fixed interpolation error. --- .../java/org/orekit/rugged/core/dem/SimpleTile.java | 4 ++-- .../org/orekit/rugged/core/dem/SimpleTileTest.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) 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 38d79301..9503e0b1 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 a2ce7df9..2e5844f1 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 { -- GitLab