From 319a81594e5685965473e9f92d34cc82c70aa37b Mon Sep 17 00:00:00 2001 From: Luc Maisonobe <luc@orekit.org> Date: Thu, 9 Dec 2021 17:24:55 +0100 Subject: [PATCH] Clarified test. --- .../java/org/orekit/rugged/api/Rugged.java | 14 +++++++++---- .../refraction/AtmosphericRefractionTest.java | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/orekit/rugged/api/Rugged.java b/src/main/java/org/orekit/rugged/api/Rugged.java index 2f5a1695..a0fdab46 100644 --- a/src/main/java/org/orekit/rugged/api/Rugged.java +++ b/src/main/java/org/orekit/rugged/api/Rugged.java @@ -814,10 +814,7 @@ public class Rugged { } // Check if the pixel is inside the sensor (with a margin) OR if the inverse location was impossible (null result) - if (sensorPixelGrid[uIndex][vIndex] != null && - (sensorPixelGrid[uIndex][vIndex].getPixelNumber() < -INVLOC_MARGIN || - sensorPixelGrid[uIndex][vIndex].getPixelNumber() > (INVLOC_MARGIN + sensor.getNbPixels() - 1)) || - sensorPixelGrid[uIndex][vIndex] == null) { + if (!pixelIsInside(sensorPixelGrid[uIndex][vIndex], sensor)) { // In order for the dump to end nicely DumpManager.endNicely(); // Impossible to find the point in the given min line @@ -839,6 +836,15 @@ public class Rugged { return sensorPixelGrid; } + /** Check if pixel is inside the sensor with a margin. + * @param pixel pixel to check (may be null if not found) + * @param sensor the line sensor + * @return true if the pixel is inside the sensor + */ + private boolean pixelIsInside(final SensorPixel pixel, final LineSensor sensor) { + return pixel != null && pixel.getPixelNumber() >= -INVLOC_MARGIN && pixel.getPixelNumber() < INVLOC_MARGIN + sensor.getNbPixels() - 1; + } + /** Computation, for the sensor pixels grid, of the direct location WITH atmospheric refraction. * (full computation) * @param pixelGrid the pixel grid diff --git a/src/test/java/org/orekit/rugged/refraction/AtmosphericRefractionTest.java b/src/test/java/org/orekit/rugged/refraction/AtmosphericRefractionTest.java index ab6bf69e..9a0dd896 100644 --- a/src/test/java/org/orekit/rugged/refraction/AtmosphericRefractionTest.java +++ b/src/test/java/org/orekit/rugged/refraction/AtmosphericRefractionTest.java @@ -120,9 +120,29 @@ public class AtmosphericRefractionTest { GeodeticPoint dummyGP = new GeodeticPoint(dummyLat, dummyLon, 0.); try { ruggedWith.inverseLocation(sensorName, dummyGP, minLine, maxLine); + Assert.fail("an exeption should have been thrown"); } catch (RuggedException re) { Assert.assertEquals(RuggedMessages.INVALID_RANGE_FOR_LINES, re.getSpecifier()); } + + try { + ruggedWith.inverseLocation(sensorName, + gpWithAtmosphericRefractionCorrection[0], + 210, maxLine); + Assert.fail("an exeption should have been thrown"); + } catch (RuggedException re) { + Assert.assertEquals(RuggedMessages.INVALID_RANGE_FOR_LINES, re.getSpecifier()); + } + + try { + ruggedWith.inverseLocation(sensorName, + gpWithAtmosphericRefractionCorrection[0], + minLine, 190); + Assert.fail("an exeption should have been thrown"); + } catch (RuggedException re) { + Assert.assertEquals(RuggedMessages.INVALID_RANGE_FOR_LINES, re.getSpecifier()); + } + } private RuggedBuilder initRuggedForAtmosphericTests(final int dimension, final String sensorName) throws URISyntaxException { -- GitLab