From bbcd65e5f6919177b4c9e078622a0d6c4d834f41 Mon Sep 17 00:00:00 2001 From: Guylaine Prat <guylaine.prat@c-s.fr> Date: Wed, 27 Feb 2019 16:35:52 +0100 Subject: [PATCH] Enable null in dump of direct or inverse location results --- .../java/org/orekit/rugged/errors/Dump.java | 4 ++ .../orekit/rugged/errors/DumpReplayer.java | 45 ++++++++++++++----- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/orekit/rugged/errors/Dump.java b/src/main/java/org/orekit/rugged/errors/Dump.java index 6cf19d34..d06de7e4 100644 --- a/src/main/java/org/orekit/rugged/errors/Dump.java +++ b/src/main/java/org/orekit/rugged/errors/Dump.java @@ -170,6 +170,8 @@ class Dump { writer.format(Locale.US, "direct location result: latitude %22.15e longitude %22.15e elevation %22.15e%n", gp.getLatitude(), gp.getLongitude(), gp.getAltitude()); + } else { + writer.format(Locale.US, "direct location result: NULL"); } } @@ -203,6 +205,8 @@ class Dump { writer.format(Locale.US, "inverse location result: lineNumber %22.15e pixelNumber %22.15e%n", pixel.getLineNumber(), pixel.getPixelNumber()); + } else { + writer.format(Locale.US, "inverse location result: NULL"); } } diff --git a/src/main/java/org/orekit/rugged/errors/DumpReplayer.java b/src/main/java/org/orekit/rugged/errors/DumpReplayer.java index 12f3713b..74ba8052 100644 --- a/src/main/java/org/orekit/rugged/errors/DumpReplayer.java +++ b/src/main/java/org/orekit/rugged/errors/DumpReplayer.java @@ -221,6 +221,9 @@ public class DumpReplayer { /** Keyword for target direction. */ private static final String TARGET_DIRECTION = "targetDirection"; + /** Keyword for null result. */ + private static final String NULL_RESULT = "NULL"; + /** Constant elevation for constant elevation algorithm. */ private double constantElevation; @@ -595,15 +598,24 @@ public class DumpReplayer { /** {@inheritDoc} */ @Override public void parse(final int l, final File file, final String line, final String[] fields, final DumpReplayer global) { - if (fields.length < 6 || !fields[0].equals(LATITUDE) || - !fields[2].equals(LONGITUDE) || !fields[4].equals(ELEVATION)) { + if (fields.length == 1) { + if (fields[0].equals(NULL_RESULT)) { + final GeodeticPoint gp = null; + final DumpedCall last = global.calls.get(global.calls.size() - 1); + last.expected = gp; + } else { + throw new RuggedException(RuggedMessages.CANNOT_PARSE_LINE, l, file, line); + } + } else if (fields.length < 6 || !fields[0].equals(LATITUDE) || + !fields[2].equals(LONGITUDE) || !fields[4].equals(ELEVATION)) { throw new RuggedException(RuggedMessages.CANNOT_PARSE_LINE, l, file, line); + } else { + final GeodeticPoint gp = new GeodeticPoint(Double.parseDouble(fields[1]), + Double.parseDouble(fields[3]), + Double.parseDouble(fields[5])); + final DumpedCall last = global.calls.get(global.calls.size() - 1); + last.expected = gp; } - final GeodeticPoint gp = new GeodeticPoint(Double.parseDouble(fields[1]), - Double.parseDouble(fields[3]), - Double.parseDouble(fields[5])); - final DumpedCall last = global.calls.get(global.calls.size() - 1); - last.expected = gp; } }, @@ -806,13 +818,22 @@ public class DumpReplayer { /** {@inheritDoc} */ @Override public void parse(final int l, final File file, final String line, final String[] fields, final DumpReplayer global) { - if (fields.length < 4 || !fields[0].equals(LINE_NUMBER) || !fields[2].equals(PIXEL_NUMBER)) { + if (fields.length == 1) { + if (fields[0].equals(NULL_RESULT)) { + final SensorPixel sp = null; + final DumpedCall last = global.calls.get(global.calls.size() - 1); + last.expected = sp; + } else { + throw new RuggedException(RuggedMessages.CANNOT_PARSE_LINE, l, file, line); + } + } else if (fields.length < 4 || !fields[0].equals(LINE_NUMBER) || !fields[2].equals(PIXEL_NUMBER)) { throw new RuggedException(RuggedMessages.CANNOT_PARSE_LINE, l, file, line); + } else { + final SensorPixel sp = new SensorPixel(Double.parseDouble(fields[1]), + Double.parseDouble(fields[3])); + final DumpedCall last = global.calls.get(global.calls.size() - 1); + last.expected = sp; } - final SensorPixel sp = new SensorPixel(Double.parseDouble(fields[1]), - Double.parseDouble(fields[3])); - final DumpedCall last = global.calls.get(global.calls.size() - 1); - last.expected = sp; } }, -- GitLab