Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • orekit/rugged
  • sdinot/rugged
  • yzokras/rugged
  • youngcle/rugged-mod
4 results
Show changes
Showing
with 1845 additions and 1792 deletions
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.rugged.api;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
import org.orekit.rugged.linesensor.SensorPixel;
/** Container for mapping between sensor A pixels and sensor B pixels
* and storing distance between the two LOS computed with @link {@link Rugged#distanceBetweenLOS(
* String, org.orekit.time.AbsoluteDate, int, String, org.orekit.time.AbsoluteDate, int)}
* @author Lucie LabatAllee
* @since 2.0
*/
public class SensorToSensorMapping {
/** Name of the sensors to which mapping applies. */
private final String sensorNameA;
private final String sensorNameB;
/** Mapping from sensor A to sensor B. */
private final Map<SensorPixel, SensorPixel> sensorToSensor;
/** Distance between two LOS */
private final Collection<Double> mapDistance;
/** Build a new instance.
* @param sensorNameA name of the sensor A to which mapping applies
* @param sensorNameB name of the sensor B to which mapping applies
*/
public SensorToSensorMapping(final String sensorNameA, final String sensorNameB) {
this.sensorNameA = sensorNameA;
this.sensorNameB = sensorNameB;
this.sensorToSensor = new IdentityHashMap<>();
this.mapDistance = new ArrayList<Double>();
}
/** Get the name of the sensor A to which mapping applies.
* @return name of the sensor A to which mapping applies
*/
public String getSensorNameA() {
return sensorNameA;
}
/** Get the name of the sensor B to which mapping applies.
* @return name of the sensor B to which mapping applies
*/
public String getSensorNameB() {
return sensorNameB;
}
/** Add a mapping between one sensor A pixel to one sensor B pixel and computed distance between both LOS
* @param pixelA sensor A pixel
* @param pixelB sensor B pixel corresponding to the sensor A pixel
*/
public void addMapping(final SensorPixel pixelA, final SensorPixel pixelB, final double distance) {
sensorToSensor.put(pixelA, pixelB);
mapDistance.add(distance);
}
/** Get all the mapping entries.
* @return an unmodifiable view of all mapping entries
*/
public Set<Map.Entry<SensorPixel, SensorPixel>> getMappings() {
return Collections.unmodifiableSet(sensorToSensor.entrySet());
}
/**
* @return the mapDistance
*/
public Collection<Double> getMapDistance() {
return mapDistance;
}
}
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* This package provides the principal class of Rugged library API, as well as
* the builder for Rugged instances.
*
* @author Luc Maisonobe
* @author Guylaine Prat
*
*/
package org.orekit.rugged.api;
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -31,7 +31,6 @@ import org.hipparchus.util.FastMath;
import org.hipparchus.util.OpenIntToDoubleHashMap;
import org.hipparchus.util.Pair;
import org.orekit.bodies.GeodeticPoint;
import org.orekit.errors.OrekitException;
import org.orekit.frames.FactoryManagedFrame;
import org.orekit.frames.Frame;
import org.orekit.frames.Transform;
......@@ -49,6 +48,7 @@ import org.orekit.time.TimeScalesFactory;
/**
* Dump data class.
* @author Luc Maisonobe
* @author Guylaine Prat
*/
class Dump {
......@@ -75,8 +75,8 @@ class Dump {
*/
Dump(final PrintWriter writer) {
this.writer = writer;
this.tiles = new ArrayList<DumpedTileData>();
this.sensors = new ArrayList<DumpedSensorData>();
this.tiles = new ArrayList<>();
this.sensors = new ArrayList<>();
this.algorithmDumped = false;
this.ellipsoidDumped = false;
this.tranformsDumped = null;
......@@ -145,33 +145,33 @@ class Dump {
/** Dump a direct location computation.
* @param date date of the location
* @param position pixel position in spacecraft frame
* @param sensorPosition sensor position in spacecraft frame
* @param los normalized line-of-sight in spacecraft frame
* @param lightTimeCorrection flag for light time correction
* @param aberrationOfLightCorrection flag for aberration of light correction
* @exception RuggedException if date cannot be converted to UTC
* @param refractionCorrection flag for refraction correction
*/
public void dumpDirectLocation(final AbsoluteDate date, final Vector3D position, final Vector3D los,
final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection)
throws RuggedException {
public void dumpDirectLocation(final AbsoluteDate date, final Vector3D sensorPosition, final Vector3D los,
final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection,
final boolean refractionCorrection) {
writer.format(Locale.US,
"direct location: date %s position %22.15e %22.15e %22.15e los %22.15e %22.15e %22.15e lightTime %b aberration %b%n",
"direct location: date %s position %22.15e %22.15e %22.15e los %22.15e %22.15e %22.15e lightTime %b aberration %b refraction %b %n",
convertDate(date),
position.getX(), position.getY(), position.getZ(),
sensorPosition.getX(), sensorPosition.getY(), sensorPosition.getZ(),
los.getX(), los.getY(), los.getZ(),
lightTimeCorrection, aberrationOfLightCorrection);
lightTimeCorrection, aberrationOfLightCorrection, refractionCorrection);
}
/** Dump a direct location result.
* @param gp resulting geodetic point
* @exception RuggedException if date cannot be converted to UTC
*/
public void dumpDirectLocationResult(final GeodeticPoint gp)
throws RuggedException {
public void dumpDirectLocationResult(final GeodeticPoint gp) {
if (gp != null) {
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");
}
}
......@@ -182,17 +182,19 @@ class Dump {
* @param maxLine maximum line number
* @param lightTimeCorrection flag for light time correction
* @param aberrationOfLightCorrection flag for aberration of light correction
* @param refractionCorrection flag for refraction correction
*/
public void dumpInverseLocation(final LineSensor sensor, final GeodeticPoint point,
final int minLine, final int maxLine,
final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection) {
final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection,
final boolean refractionCorrection) {
final DumpedSensorData ds = getSensorData(sensor);
writer.format(Locale.US,
"inverse location: sensorName %s latitude %22.15e longitude %22.15e elevation %22.15e minLine %d maxLine %d lightTime %b aberration %b%n",
"inverse location: sensorName %s latitude %22.15e longitude %22.15e elevation %22.15e minLine %d maxLine %d lightTime %b aberration %b refraction %b %n",
ds.getDumpName(),
point.getLatitude(), point.getLongitude(), point.getAltitude(),
minLine, maxLine,
lightTimeCorrection, aberrationOfLightCorrection);
lightTimeCorrection, aberrationOfLightCorrection, refractionCorrection);
}
/** Dump an inverse location result.
......@@ -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");
}
}
......@@ -211,11 +215,9 @@ class Dump {
* @param index index of the transform
* @param bodyToInertial transform from body frame to inertial frame
* @param scToInertial transfrom from spacecraft frame to inertial frame
* @exception RuggedException if reference date cannot be converted to UTC
*/
public void dumpTransform(final SpacecraftToObservedBody scToBody, final int index,
final Transform bodyToInertial, final Transform scToInertial)
throws RuggedException {
final Transform bodyToInertial, final Transform scToInertial) {
if (tranformsDumped == null) {
final AbsoluteDate minDate = scToBody.getMinDate();
final AbsoluteDate maxDate = scToBody.getMaxDate();
......@@ -241,10 +243,8 @@ class Dump {
/** Dump a sensor mean plane.
* @param meanPlane mean plane associated with sensor
* @exception RuggedException if some frames cannot be computed at mid date
*/
public void dumpSensorMeanPlane(final SensorMeanPlaneCrossing meanPlane)
throws RuggedException {
public void dumpSensorMeanPlane(final SensorMeanPlaneCrossing meanPlane) {
getSensorData(meanPlane.getSensor()).setMeanPlane(meanPlane);
}
......@@ -253,10 +253,8 @@ class Dump {
* @param date date
* @param i pixel index
* @param los pixel normalized line-of-sight
* @exception RuggedException if date cannot be converted to UTC
*/
public void dumpSensorLOS(final LineSensor sensor, final AbsoluteDate date, final int i, final Vector3D los)
throws RuggedException {
public void dumpSensorLOS(final LineSensor sensor, final AbsoluteDate date, final int i, final Vector3D los) {
getSensorData(sensor).setLOS(date, i, los);
}
......@@ -264,10 +262,8 @@ class Dump {
* @param sensor sensor
* @param lineNumber line number
* @param date date
* @exception RuggedException if date cannot be converted to UTC
*/
public void dumpSensorDatation(final LineSensor sensor, final double lineNumber, final AbsoluteDate date)
throws RuggedException {
public void dumpSensorDatation(final LineSensor sensor, final double lineNumber, final AbsoluteDate date) {
getSensorData(sensor).setDatation(lineNumber, date);
}
......@@ -343,18 +339,12 @@ class Dump {
/** Convert a date to string with high accuracy.
* @param date computation date
* @return converted date
* @exception RuggedException if date cannot be converted to UTC
*/
private String convertDate(final AbsoluteDate date)
throws RuggedException {
try {
final DateTimeComponents dt = date.getComponents(TimeScalesFactory.getUTC());
return String.format(Locale.US, "%04d-%02d-%02dT%02d:%02d:%017.14fZ",
dt.getDate().getYear(), dt.getDate().getMonth(), dt.getDate().getDay(),
dt.getTime().getHour(), dt.getTime().getMinute(), dt.getTime().getSecond());
} catch (OrekitException oe) {
throw new RuggedException(oe, oe.getSpecifier(), oe.getParts());
}
private String convertDate(final AbsoluteDate date) {
final DateTimeComponents dt = date.getComponents(TimeScalesFactory.getUTC());
return String.format(Locale.US, "%04d-%02d-%02dT%02d:%02d:%017.14fZ",
dt.getDate().getYear(), dt.getDate().getMonth(), dt.getDate().getDay(),
dt.getTime().getHour(), dt.getTime().getMinute(), dt.getTime().getSecond());
}
/** Convert a translation to string.
......@@ -496,46 +486,41 @@ class Dump {
/** Set the mean plane finder.
* @param meanPlane mean plane finder
* @exception RuggedException if frames cannot be computed at mid date
*/
public void setMeanPlane(final SensorMeanPlaneCrossing meanPlane) throws RuggedException {
try {
if (this.meanPlane == null) {
this.meanPlane = meanPlane;
final long nbResults = meanPlane.getCachedResults().count();
writer.format(Locale.US,
"sensor mean plane: sensorName %s minLine %d maxLine %d maxEval %d accuracy %22.15e normal %22.15e %22.15e %22.15e cachedResults %d",
dumpName,
meanPlane.getMinLine(), meanPlane.getMaxLine(),
meanPlane.getMaxEval(), meanPlane.getAccuracy(),
meanPlane.getMeanPlaneNormal().getX(), meanPlane.getMeanPlaneNormal().getY(), meanPlane.getMeanPlaneNormal().getZ(),
nbResults);
meanPlane.getCachedResults().forEach(result -> {
try {
writer.format(Locale.US,
" lineNumber %22.15e date %s target %22.15e %22.15e %22.15e targetDirection %22.15e %22.15e %22.15e %22.15e %22.15e %22.15e",
result.getLine(), convertDate(result.getDate()),
result.getTarget().getX(), result.getTarget().getY(), result.getTarget().getZ(),
result.getTargetDirection().getX(),
result.getTargetDirection().getY(),
result.getTargetDirection().getZ(),
result.getTargetDirectionDerivative().getZ(),
result.getTargetDirectionDerivative().getY(),
result.getTargetDirectionDerivative().getZ());
} catch (RuggedException re) {
throw new RuggedExceptionWrapper(re);
}
});
writer.format(Locale.US, "%n");
// ensure the transforms for mid date are dumped
final AbsoluteDate midDate = meanPlane.getSensor().getDate(0.5 * (meanPlane.getMinLine() + meanPlane.getMaxLine()));
meanPlane.getScToBody().getBodyToInertial(midDate);
meanPlane.getScToBody().getScToInertial(midDate);
public void setMeanPlane(final SensorMeanPlaneCrossing meanPlane) {
}
} catch (RuggedExceptionWrapper rew) {
throw rew.getException();
if (this.meanPlane == null) {
this.meanPlane = meanPlane;
final long nbResults = meanPlane.getCachedResults().count();
writer.format(Locale.US,
"sensor mean plane: sensorName %s minLine %d maxLine %d maxEval %d accuracy %22.15e normal %22.15e %22.15e %22.15e cachedResults %d",
dumpName,
meanPlane.getMinLine(), meanPlane.getMaxLine(),
meanPlane.getMaxEval(), meanPlane.getAccuracy(),
meanPlane.getMeanPlaneNormal().getX(), meanPlane.getMeanPlaneNormal().getY(), meanPlane.getMeanPlaneNormal().getZ(),
nbResults);
meanPlane.getCachedResults().forEach(result -> {
try {
writer.format(Locale.US,
" lineNumber %22.15e date %s target %22.15e %22.15e %22.15e targetDirection %22.15e %22.15e %22.15e %22.15e %22.15e %22.15e",
result.getLine(), convertDate(result.getDate()),
result.getTarget().getX(), result.getTarget().getY(), result.getTarget().getZ(),
result.getTargetDirection().getX(),
result.getTargetDirection().getY(),
result.getTargetDirection().getZ(),
result.getTargetDirectionDerivative().getZ(),
result.getTargetDirectionDerivative().getY(),
result.getTargetDirectionDerivative().getZ());
} catch (RuggedException re) {
throw new RuggedInternalError(re);
}
});
writer.format(Locale.US, "%n");
// ensure the transforms for mid date are dumped
final AbsoluteDate midDate = meanPlane.getSensor().getDate(0.5 * (meanPlane.getMinLine() + meanPlane.getMaxLine()));
meanPlane.getScToBody().getBodyToInertial(midDate);
meanPlane.getScToBody().getScToInertial(midDate);
}
}
......@@ -543,10 +528,8 @@ class Dump {
* @param date date
* @param pixelNumber number of the pixel
* @param los los direction
* @exception RuggedException if date cannot be converted to UTC
*/
public void setLOS(final AbsoluteDate date, final int pixelNumber, final Vector3D los)
throws RuggedException {
public void setLOS(final AbsoluteDate date, final int pixelNumber, final Vector3D los) {
List<Pair<AbsoluteDate, Vector3D>> list = losMap.get(pixelNumber);
if (list == null) {
list = new ArrayList<Pair<AbsoluteDate, Vector3D>>();
......@@ -567,10 +550,8 @@ class Dump {
/** Set a datation pair.
* @param lineNumber line number
* @param date date
* @exception RuggedException if date cannot be converted to UTC
*/
public void setDatation(final double lineNumber, final AbsoluteDate date)
throws RuggedException {
public void setDatation(final double lineNumber, final AbsoluteDate date) {
for (final Pair<Double, AbsoluteDate> alreadyDumped : datation) {
if (FastMath.abs(date.durationFrom(alreadyDumped.getSecond())) < 1.0e-12 &&
FastMath.abs(lineNumber - alreadyDumped.getFirst()) < 1.0e-12) {
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -42,11 +42,15 @@ import org.orekit.time.AbsoluteDate;
* time, so user code should not rely on it.
* </p>
* @author Luc Maisonobe
* @author Guylaine Prat
*/
public class DumpManager {
/** Dump file (default initial value is null, i.e. nothing is dumped). */
private static final ThreadLocal<Dump> DUMP = new ThreadLocal<Dump>();
private static final ThreadLocal<Dump> DUMP = new ThreadLocal<>();
/** Boolean to check if the dump is suspended. */
private static boolean isSuspended = false;
/** Private constructor for utility class.
*/
......@@ -56,10 +60,8 @@ public class DumpManager {
/** Activate debug dump.
* @param file dump file
* @exception RuggedException if debug dump is already active for this thread
* or if debug file cannot be opened
*/
public static void activate(final File file) throws RuggedException {
public static void activate(final File file) {
if (isActive()) {
throw new RuggedException(RuggedMessages.DEBUG_DUMP_ALREADY_ACTIVE);
} else {
......@@ -73,9 +75,8 @@ public class DumpManager {
}
/** Deactivate debug dump.
* @exception RuggedException if debug dump is already active for this thread
*/
public static void deactivate() throws RuggedException {
public static void deactivate() {
if (isActive()) {
DUMP.get().deactivate();
DUMP.set(null);
......@@ -84,11 +85,44 @@ public class DumpManager {
}
}
/** Suspend the dump.
* In case the dump is already suspended, keep the previous status in order to
* correctly deal the resume stage.
* @return a flag to tell if the dump is already suspended (true; false otherwise)
*/
public static Boolean suspend() {
// Check if the dump is already suspended
if (isSuspended) {
return isSuspended;
} else {
isSuspended = true;
return false;
}
}
/** Resume the dump, only if it was not already suspended.
* @param wasSuspended flag to tell if the dump was already suspended (true; false otherwise)
*/
public static void resume(final Boolean wasSuspended) {
if (!wasSuspended) {
isSuspended = false;
}
}
/** In case dump is suspended and an exception is thrown,
* allows the dump to end nicely.
*/
public static void endNicely() {
isSuspended = false;
if (isActive()) deactivate();
}
/** Check if dump is active for this thread.
* @return true if dump is active for this thread
*/
public static boolean isActive() {
return DUMP.get() != null;
return DUMP.get() != null && !isSuspended;
}
/** Dump DEM cell data.
......@@ -135,26 +169,25 @@ public class DumpManager {
/** Dump a direct location computation.
* @param date date of the location
* @param position pixel position in spacecraft frame
* @param sensorPosition sensor position in spacecraft frame
* @param los normalized line-of-sight in spacecraft frame
* @param lightTimeCorrection flag for light time correction
* @param aberrationOfLightCorrection flag for aberration of light correction
* @exception RuggedException if date cannot be converted to UTC
* @param refractionCorrection flag for refraction correction
*/
public static void dumpDirectLocation(final AbsoluteDate date, final Vector3D position, final Vector3D los,
final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection)
throws RuggedException {
public static void dumpDirectLocation(final AbsoluteDate date, final Vector3D sensorPosition, final Vector3D los,
final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection,
final boolean refractionCorrection) {
if (isActive()) {
DUMP.get().dumpDirectLocation(date, position, los, lightTimeCorrection, aberrationOfLightCorrection);
DUMP.get().dumpDirectLocation(date, sensorPosition, los, lightTimeCorrection, aberrationOfLightCorrection,
refractionCorrection);
}
}
/** Dump a direct location result.
* @param gp resulting geodetic point
* @exception RuggedException if date cannot be converted to UTC
*/
public static void dumpDirectLocationResult(final GeodeticPoint gp)
throws RuggedException {
public static void dumpDirectLocationResult(final GeodeticPoint gp) {
if (isActive()) {
DUMP.get().dumpDirectLocationResult(gp);
}
......@@ -163,17 +196,22 @@ public class DumpManager {
/** Dump an inverse location computation.
* @param sensor sensor
* @param point point to localize
* @param ellipsoid the used ellipsoid
* @param minLine minimum line number
* @param maxLine maximum line number
* @param lightTimeCorrection flag for light time correction
* @param aberrationOfLightCorrection flag for aberration of light correction
* @param refractionCorrection flag for refraction correction
*/
public static void dumpInverseLocation(final LineSensor sensor, final GeodeticPoint point,
final ExtendedEllipsoid ellipsoid,
final int minLine, final int maxLine,
final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection) {
final boolean lightTimeCorrection, final boolean aberrationOfLightCorrection,
final boolean refractionCorrection) {
if (isActive()) {
DUMP.get().dumpInverseLocation(sensor, point, minLine, maxLine,
lightTimeCorrection, aberrationOfLightCorrection);
lightTimeCorrection, aberrationOfLightCorrection, refractionCorrection);
DUMP.get().dumpEllipsoid(ellipsoid);
}
}
......@@ -191,11 +229,9 @@ public class DumpManager {
* @param index index of the transform
* @param bodyToInertial transform from body frame to inertial frame
* @param scToInertial transfrom from spacecraft frame to inertial frame
* @exception RuggedException if reference date cannot be converted to UTC
*/
public static void dumpTransform(final SpacecraftToObservedBody scToBody, final int index,
final Transform bodyToInertial, final Transform scToInertial)
throws RuggedException {
final Transform bodyToInertial, final Transform scToInertial) {
if (isActive()) {
DUMP.get().dumpTransform(scToBody, index, bodyToInertial, scToInertial);
}
......@@ -203,10 +239,8 @@ public class DumpManager {
/** Dump a sensor mean plane.
* @param meanPlane mean plane associated with sensor
* @exception RuggedException if some frames cannot be computed at mid date
*/
public static void dumpSensorMeanPlane(final SensorMeanPlaneCrossing meanPlane)
throws RuggedException {
public static void dumpSensorMeanPlane(final SensorMeanPlaneCrossing meanPlane) {
if (isActive()) {
DUMP.get().dumpSensorMeanPlane(meanPlane);
}
......@@ -217,10 +251,8 @@ public class DumpManager {
* @param date date
* @param i pixel index
* @param los pixel normalized line-of-sight
* @exception RuggedException if date cannot be converted to UTC
*/
public static void dumpSensorLOS(final LineSensor sensor, final AbsoluteDate date, final int i, final Vector3D los)
throws RuggedException {
public static void dumpSensorLOS(final LineSensor sensor, final AbsoluteDate date, final int i, final Vector3D los) {
if (isActive()) {
DUMP.get().dumpSensorLOS(sensor, date, i, los);
}
......@@ -230,10 +262,8 @@ public class DumpManager {
* @param sensor sensor
* @param lineNumber line number
* @param date date
* @exception RuggedException if date cannot be converted to UTC
*/
public static void dumpSensorDatation(final LineSensor sensor, final double lineNumber, final AbsoluteDate date)
throws RuggedException {
public static void dumpSensorDatation(final LineSensor sensor, final double lineNumber, final AbsoluteDate date) {
if (isActive()) {
DUMP.get().dumpSensorDatation(sensor, lineNumber, date);
}
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -27,15 +27,15 @@ import org.hipparchus.exception.LocalizedException;
* the rugged library classes.
* <p>
* This class is heavily based on Orekit {@link org.orekit.errors.OrekitException},
* This class is heavily based on {@code OrekitException},
* which is distributed under the terms of the Apache License V2.
* </p>
*
* @author Luc Maisonobe
* @author Guylaine Prat
*/
public class RuggedException extends Exception implements LocalizedException {
public class RuggedException extends RuntimeException implements LocalizedException {
/** Serializable UID. */
private static final long serialVersionUID = 20140309L;
......@@ -51,7 +51,7 @@ public class RuggedException extends Exception implements LocalizedException {
* @param specifier format specifier (to be translated)
* @param parts parts to insert in the format (no translation)
*/
public RuggedException(final Localizable specifier, final Object ... parts) {
public RuggedException(final Localizable specifier, final Object... parts) {
this.specifier = specifier;
this.parts = (parts == null) ? new Object[0] : parts.clone();
}
......@@ -63,7 +63,7 @@ public class RuggedException extends Exception implements LocalizedException {
* @param parts parts to insert in the format (no translation)
*/
public RuggedException(final Throwable cause, final Localizable specifier,
final Object ... parts) {
final Object... parts) {
super(cause);
this.specifier = specifier;
this.parts = (parts == null) ? new Object[0] : parts.clone();
......@@ -109,41 +109,8 @@ public class RuggedException extends Exception implements LocalizedException {
* @return a message string
*/
private static String buildMessage(final Locale locale, final Localizable specifier,
final Object ... parts) {
final Object... parts) {
return (specifier == null) ? "" : new MessageFormat(specifier.getLocalizedString(locale), locale).format(parts);
}
/** Create an {@link java.lang.RuntimeException} for an internal error.
* @param cause underlying cause
* @return an {@link java.lang.RuntimeException} for an internal error
*/
public static RuntimeException createInternalError(final Throwable cause) {
/** Format specifier (to be translated). */
final Localizable specifier = RuggedMessages.INTERNAL_ERROR;
/** Parts to insert in the format (no translation). */
final String parts = "rugged-developers@orekit.org";
return new RuntimeException() {
/** Serializable UID. */
private static final long serialVersionUID = 20140309L;
/** {@inheritDoc} */
@Override
public String getMessage() {
return buildMessage(Locale.US, specifier, parts);
}
/** {@inheritDoc} */
@Override
public String getLocalizedMessage() {
return buildMessage(Locale.getDefault(), specifier, parts);
}
};
}
}
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -22,11 +22,15 @@ package org.orekit.rugged.errors;
* this exception. Typical examples are propagation methods that are used inside Hipparchus
* optimizers, integrators or solvers.</p>
* <p>
* This class is heavily based on Orekit {@link org.orekit.errors.OrekitException},
* This class is heavily based on {@code OrekitException},
* which is distributed under the terms of the Apache License V2.
* </p>
* @author Luc Maisonobe
* @author Guylaine Prat
* @deprecated as of 2.1, this class is not used anymore, as {@link RuggedException}
* is now an unchecked exception
*/
@Deprecated
public class RuggedExceptionWrapper extends RuntimeException {
/** serializable UID. */
......
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.rugged.errors;
import java.text.MessageFormat;
import java.util.Locale;
import org.hipparchus.exception.Localizable;
import org.hipparchus.exception.LocalizedException;
/** Extension of {@link java.lang.Runtime} with localized message for internal errors only.
* @since 2.1
*/
public class RuggedInternalError extends RuntimeException implements LocalizedException {
/** Serializable UID. */
private static final long serialVersionUID = 20190305L;
/** Format specifier (to be translated). */
private final Localizable specifier = RuggedMessages.INTERNAL_ERROR;
/** Parts to insert in the format (no translation). */
private final String[] parts = new String[] {
"https://gitlab.orekit.org/orekit/rugged/issues"
};
/** Create an exception with localized message.
* @param cause underlying cause
*/
public RuggedInternalError(final Throwable cause) {
super(cause);
}
/** {@inheritDoc} */
@Override
public String getMessage(final Locale locale) {
return buildMessage(locale);
}
/** {@inheritDoc} */
@Override
public String getMessage() {
return buildMessage(Locale.US);
}
/** {@inheritDoc} */
@Override
public String getLocalizedMessage() {
return buildMessage(Locale.getDefault());
}
/** {@inheritDoc} */
@Override
public Localizable getSpecifier() {
return specifier;
}
/** {@inheritDoc} */
@Override
public Object[] getParts() {
return parts.clone();
}
/**
* Builds a message string by from a pattern and its arguments.
* @param locale Locale in which the message should be translated
* @return a message string
*/
private String buildMessage(final Locale locale) {
return new MessageFormat(specifier.getLocalizedString(locale), locale).format(parts);
}
}
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -16,17 +16,19 @@
*/
package org.orekit.rugged.errors;
import org.hipparchus.exception.Localizable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import org.hipparchus.exception.Localizable;
/**
* Enumeration for localized messages formats.
......@@ -42,7 +44,7 @@ import java.util.ResourceBundle;
* translation is missing.
* </p>
* <p>
* This class is heavily based on Orekit {@link org.orekit.errors.OrekitMessages},
* This class is heavily based on {@code OrekitMessages},
* which is distributed under the terms of the Apache License V2.
* </p>
*/
......@@ -50,7 +52,7 @@ public enum RuggedMessages implements Localizable {
// CHECKSTYLE: stop JavadocVariable check
INTERNAL_ERROR("internal error, contact maintenance at {0}"),
INTERNAL_ERROR("internal error, please notify development team by creating an issue at {0}"),
OUT_OF_TILE_INDICES("no data at indices [{0}, {1}], tile only covers from [0, 0] to [{2}, {3}] (inclusive)"),
OUT_OF_TILE_ANGLES("no data at latitude {0} and longitude {1}, tile covers only latitudes {2} to {3} and longitudes {4} to {5}"),
NO_DEM_DATA("no Digital Elevation Model data at latitude {0} and longitude {1}"),
......@@ -66,18 +68,26 @@ public enum RuggedMessages implements Localizable {
DEM_ENTRY_POINT_IS_BEHIND_SPACECRAFT("line-of-sight enters the Digital Elevation Model behind spacecraft!"),
FRAMES_MISMATCH_WITH_INTERPOLATOR_DUMP("frame {0} does not match frame {1} from interpolator dump"),
NOT_INTERPOLATOR_DUMP_DATA("data is not an interpolator dump"),
ESTIMATED_PARAMETERS_NUMBER_MISMATCH("number of estimated parameters mismatch, expected {0} got {1}"),
DEBUG_DUMP_ALREADY_ACTIVE("debug dump is already active for this thread"),
DEBUG_DUMP_ACTIVATION_ERROR("unable to active debug dump with file {0}: {1}"),
DEBUG_DUMP_NOT_ACTIVE("debug dump is not active for this thread"),
CANNOT_PARSE_LINE("cannot parse line {0}, file {1}: {2}"),
LIGHT_TIME_CORRECTION_REDEFINED("light time correction redefined, line {0}, file {1}: {2}"),
ABERRATION_OF_LIGHT_CORRECTION_REDEFINED("aberration of light correction redefined, line {0}, file {1}: {2}"),
ATMOSPHERIC_REFRACTION_REDEFINED("atmospheric refraction correction redefined, line {0}, file {1}: {2}"),
TILE_ALREADY_DEFINED("tile {0} already defined, line {1}, file {2}: {3}"),
UNKNOWN_TILE("unknown tile {0}, line {1}, file {2}: {3}"),
NO_PARAMETERS_SELECTED("no parameters have been selected for estimation"),
NO_REFERENCE_MAPPINGS("no reference mappings for parameters estimation"),
DUPLICATED_PARAMETER_NAME("a different parameter with name {0} already exists");
DUPLICATED_PARAMETER_NAME("a different parameter with name {0} already exists"),
INVALID_RUGGED_NAME("invalid rugged name"),
UNSUPPORTED_REFINING_CONTEXT("refining using {0} rugged instance is not handled"),
NO_LAYER_DATA("no atmospheric layer data at altitude {0} (lowest altitude: {1})"),
INVALID_STEP("step {0} is not valid : {1}"),
INVALID_RANGE_FOR_LINES("range between min line {0} and max line {1} is invalid {2}"),
SENSOR_PIXEL_NOT_FOUND_IN_RANGE_LINES("impossible to find sensor pixel in given range lines (with atmospheric refraction) between lines {0} and {1}"),
SENSOR_PIXEL_NOT_FOUND_IN_PIXELS_LINE("impossible to find sensor pixel: pixel {0} outside interval [ {1} , {2} [ (with atmospheric refraction margin = {3})");
// CHECKSTYLE: resume JavadocVariable check
......@@ -96,20 +106,21 @@ public enum RuggedMessages implements Localizable {
}
/** {@inheritDoc} */
@Override
public String getSourceString() {
return sourceFormat;
}
/** {@inheritDoc} */
@Override
public String getLocalizedString(final Locale locale) {
try {
final ResourceBundle bundle =
ResourceBundle.getBundle(RESOURCE_BASE_NAME, locale, new UTF8Control());
if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
final String translated = bundle.getString(name());
if ((translated != null) &&
(translated.length() > 0) &&
(!translated.toLowerCase().contains("missing translation"))) {
if (translated.length() > 0 &&
!translated.toLowerCase(locale).contains("missing translation")) {
// the value of the resource is the translated format
return translated;
}
......@@ -137,8 +148,7 @@ public enum RuggedMessages implements Localizable {
/** {@inheritDoc} */
@Override
public ResourceBundle newBundle(final String baseName, final Locale locale, final String format,
final ClassLoader loader, final boolean reload)
throws IllegalAccessException, InstantiationException, IOException {
final ClassLoader loader, final boolean reload) throws IOException {
// The below is a copy of the default implementation.
final String bundleName = toBundleName(baseName, locale);
final String resourceName = toResourceName(bundleName, "utf8");
......@@ -157,11 +167,9 @@ public enum RuggedMessages implements Localizable {
stream = loader.getResourceAsStream(resourceName);
}
if (stream != null) {
try {
try (InputStreamReader inputStreamReader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
// Only this line is changed to make it to read properties files as UTF-8.
bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
} finally {
stream.close();
bundle = new PropertyResourceBundle(inputStreamReader);
}
}
return bundle;
......
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* This package provides classes to generate and handle exceptions.
*
* @author Luc Maisonobe
* @author Guylaine Prat
*
*/
package org.orekit.rugged.errors;