Skip to content
Snippets Groups Projects
Commit 7914c3e7 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Added a protection against unknown sensors.

parent d0086280
No related branches found
No related tags found
No related merge requests found
......@@ -82,7 +82,7 @@ public interface Rugged {
* @exception RuggedException if line cannot be localized,
* if {@link #setGeneralContext(File, InertialFrame, BodyRotatingFrame, Ellipsoid)} has
* not been called beforehand, or if {@link #setOrbitAndAttitude(List, List)} has not
* been called beforehand
* been called beforehand, or sensor is unknown
*/
GroundPoint[] directLocalization(String sensorName, int lineNumber)
throws RuggedException;
......@@ -94,7 +94,7 @@ public interface Rugged {
* @exception RuggedException if line cannot be localized,
* if {@link #setGeneralContext(File, InertialFrame, BodyRotatingFrame, Ellipsoid)} has
* not been called beforehand, or if {@link #setOrbitAndAttitude(List, List)} has not
* been called beforehand
* been called beforehand, or sensor is unknown
*/
SensorPixel inverseLocalization(String sensorName, GroundPoint groundPoint)
throws RuggedException;
......
......@@ -53,7 +53,8 @@ public enum RuggedMessages implements Localizable {
INTERNAL_ERROR("internal error, contact maintenance at {0}"),
OUT_OF_TILE_INDICES("no data at indices [{0}, {1}], tile only covers from [0, 0] to [{2}, {3}] (inclusive)"),
UNINITIALIZED_CONTEXT("general context has not been initialized"),
EMPTY_TILE("tile is empty: {0} ⨉ {1}");
EMPTY_TILE("tile is empty: {0} ⨉ {1}"),
UNKNOWN_SENSOR("unknown sensor {0}");
// CHECKSTYLE: resume JavadocVariable check
......
......@@ -9,3 +9,6 @@ UNINITIALIZED_CONTEXT = general context has not been initialized
# tile is empty: {0} ⨉ {1}
EMPTY_TILE = tile is empty: {0} ⨉ {1}
# unknown sensor {0}
UNKNOWN_SENSOR = unknown sensor {0}
......@@ -9,3 +9,6 @@ UNINITIALIZED_CONTEXT = le contexte général n''a pas été initialisé
# tile is empty: {0} ⨉ {1}
EMPTY_TILE = la tuile est vide : {0} ⨉ {1}
# unknown sensor {0}
UNKNOWN_SENSOR = capteur {0} inconnu
......@@ -29,7 +29,7 @@ public class RuggedMessagesTest {
@Test
public void testMessageNumber() {
Assert.assertEquals(4, RuggedMessages.values().length);
Assert.assertEquals(5, RuggedMessages.values().length);
}
@Test
......
......@@ -308,6 +308,7 @@ public abstract class AbstractRugged implements Rugged {
throws RuggedException {
checkContext();
final Sensor sensor = getSensor(sensorName);
// TODO: implement direct localization
throw RuggedException.createInternalError(null);
......@@ -320,6 +321,7 @@ public abstract class AbstractRugged implements Rugged {
throws RuggedException {
checkContext();
final Sensor sensor = getSensor(sensorName);
// TODO: implement direct localization
throw RuggedException.createInternalError(null);
......@@ -335,6 +337,19 @@ public abstract class AbstractRugged implements Rugged {
}
}
/** Get a sensor.
* @param sensorName sensor name
* @return selected sensor
* @exception RuggedException if sensor is not known
*/
private Sensor getSensor(final String sensorName) throws RuggedException {
final Sensor sensor = sensors.get(sensorName);
if (sensor == null) {
throw new RuggedException(RuggedMessages.UNKNOWN_SENSOR, sensorName);
}
return sensor;
}
/** Local container for sensor data. */
private static class Sensor {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment