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

Added dumping of algorithm.

parent 507c15cb
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ import java.util.Locale; ...@@ -24,6 +24,7 @@ import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.commons.math3.util.OpenIntToDoubleHashMap; import org.apache.commons.math3.util.OpenIntToDoubleHashMap;
import org.orekit.rugged.api.AlgorithmId;
import org.orekit.rugged.raster.Tile; import org.orekit.rugged.raster.Tile;
import org.orekit.rugged.utils.ExtendedEllipsoid; import org.orekit.rugged.utils.ExtendedEllipsoid;
...@@ -39,6 +40,9 @@ class Dump { ...@@ -39,6 +40,9 @@ class Dump {
/** Tiles map. */ /** Tiles map. */
private final List<DumpedTileData> tiles; private final List<DumpedTileData> tiles;
/** Flag for dumped algorithm. */
private boolean algorithmDumped;
/** Flag for dumped ellipsoid. */ /** Flag for dumped ellipsoid. */
private boolean ellipsoidDumped; private boolean ellipsoidDumped;
...@@ -48,6 +52,7 @@ class Dump { ...@@ -48,6 +52,7 @@ class Dump {
public Dump(final PrintWriter writer) { public Dump(final PrintWriter writer) {
this.writer = writer; this.writer = writer;
this.tiles = new ArrayList<DumpedTileData>(); this.tiles = new ArrayList<DumpedTileData>();
this.algorithmDumped = false;
this.ellipsoidDumped = false; this.ellipsoidDumped = false;
dumpHeader(); dumpHeader();
} }
...@@ -74,6 +79,31 @@ class Dump { ...@@ -74,6 +79,31 @@ class Dump {
getTileData(tile).setElevation(latitudeIndex, longitudeIndex, elevation); getTileData(tile).setElevation(latitudeIndex, longitudeIndex, elevation);
} }
/** Dump algorithm data.
* @param algorithmId algorithm ID
*/
public void dumpAlgorithm(final AlgorithmId algorithmId) {
if (!algorithmDumped) {
writer.format(Locale.US,
"algorithm: %s%n",
algorithmId.name());
algorithmDumped = true;
}
}
/** Dump algorithm data.
* @param algorithmId algorithm ID
* @param specific algorithm specific extra data
*/
public void dumpAlgorithm(final AlgorithmId algorithmId, final double specific) {
if (!algorithmDumped) {
writer.format(Locale.US,
"algorithm: %s %22.15e%n",
algorithmId.name(), specific);
algorithmDumped = true;
}
}
/** Dump ellipsoid data. /** Dump ellipsoid data.
* @param ellipsoid ellipsoid to dump * @param ellipsoid ellipsoid to dump
*/ */
......
...@@ -20,6 +20,7 @@ import java.io.File; ...@@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import org.orekit.rugged.api.AlgorithmId;
import org.orekit.rugged.raster.Tile; import org.orekit.rugged.raster.Tile;
import org.orekit.rugged.utils.ExtendedEllipsoid; import org.orekit.rugged.utils.ExtendedEllipsoid;
...@@ -96,6 +97,25 @@ public class DumpManager { ...@@ -96,6 +97,25 @@ public class DumpManager {
} }
} }
/** Dump algorithm data.
* @param algorithmId algorithm ID
*/
public static void dumpAlgorithm(final AlgorithmId algorithmId) {
if (isActive()) {
DUMP.get().dumpAlgorithm(algorithmId);
}
}
/** Dump algorithm data.
* @param algorithmId algorithm ID
* @param specific algorithm specific extra data
*/
public static void dumpAlgorithm(final AlgorithmId algorithmId, final double specific) {
if (isActive()) {
DUMP.get().dumpAlgorithm(algorithmId, specific);
}
}
/** Dump ellipsoid data. /** Dump ellipsoid data.
* @param ellipsoid ellipsoid to dump * @param ellipsoid ellipsoid to dump
*/ */
......
...@@ -23,6 +23,8 @@ import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; ...@@ -23,6 +23,8 @@ import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.FastMath;
import org.orekit.bodies.GeodeticPoint; import org.orekit.bodies.GeodeticPoint;
import org.orekit.errors.OrekitException; import org.orekit.errors.OrekitException;
import org.orekit.rugged.api.AlgorithmId;
import org.orekit.rugged.errors.DumpManager;
import org.orekit.rugged.errors.RuggedException; import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.raster.SimpleTile; import org.orekit.rugged.raster.SimpleTile;
import org.orekit.rugged.raster.SimpleTileFactory; import org.orekit.rugged.raster.SimpleTileFactory;
...@@ -68,6 +70,8 @@ public class BasicScanAlgorithm implements IntersectionAlgorithm { ...@@ -68,6 +70,8 @@ public class BasicScanAlgorithm implements IntersectionAlgorithm {
throws RuggedException { throws RuggedException {
try { try {
DumpManager.dumpAlgorithm(AlgorithmId.BASIC_SLOW_EXHAUSTIVE_SCAN_FOR_TESTS_ONLY);
// find the tiles between the entry and exit point in the Digital Elevation Model // find the tiles between the entry and exit point in the Digital Elevation Model
NormalizedGeodeticPoint entryPoint = null; NormalizedGeodeticPoint entryPoint = null;
NormalizedGeodeticPoint exitPoint = null; NormalizedGeodeticPoint exitPoint = null;
...@@ -163,6 +167,7 @@ public class BasicScanAlgorithm implements IntersectionAlgorithm { ...@@ -163,6 +167,7 @@ public class BasicScanAlgorithm implements IntersectionAlgorithm {
final NormalizedGeodeticPoint closeGuess) final NormalizedGeodeticPoint closeGuess)
throws RuggedException { throws RuggedException {
try { try {
DumpManager.dumpAlgorithm(AlgorithmId.BASIC_SLOW_EXHAUSTIVE_SCAN_FOR_TESTS_ONLY);
final Vector3D delta = ellipsoid.transform(closeGuess).subtract(position); final Vector3D delta = ellipsoid.transform(closeGuess).subtract(position);
final double s = Vector3D.dotProduct(delta, los) / los.getNormSq(); final double s = Vector3D.dotProduct(delta, los) / los.getNormSq();
final GeodeticPoint projected = ellipsoid.transform(new Vector3D(1, position, s, los), final GeodeticPoint projected = ellipsoid.transform(new Vector3D(1, position, s, los),
......
...@@ -19,6 +19,8 @@ package org.orekit.rugged.intersection; ...@@ -19,6 +19,8 @@ package org.orekit.rugged.intersection;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.orekit.bodies.GeodeticPoint; import org.orekit.bodies.GeodeticPoint;
import org.orekit.errors.OrekitException; import org.orekit.errors.OrekitException;
import org.orekit.rugged.api.AlgorithmId;
import org.orekit.rugged.errors.DumpManager;
import org.orekit.rugged.errors.RuggedException; import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.utils.ExtendedEllipsoid; import org.orekit.rugged.utils.ExtendedEllipsoid;
import org.orekit.rugged.utils.NormalizedGeodeticPoint; import org.orekit.rugged.utils.NormalizedGeodeticPoint;
...@@ -47,6 +49,7 @@ public class ConstantElevationAlgorithm implements IntersectionAlgorithm { ...@@ -47,6 +49,7 @@ public class ConstantElevationAlgorithm implements IntersectionAlgorithm {
final Vector3D position, final Vector3D los) final Vector3D position, final Vector3D los)
throws RuggedException { throws RuggedException {
try { try {
DumpManager.dumpAlgorithm(AlgorithmId.CONSTANT_ELEVATION_OVER_ELLIPSOID, constantElevation);
final Vector3D p = ellipsoid.pointAtAltitude(position, los, constantElevation); final Vector3D p = ellipsoid.pointAtAltitude(position, los, constantElevation);
final GeodeticPoint gp = ellipsoid.transform(p, ellipsoid.getFrame(), null); final GeodeticPoint gp = ellipsoid.transform(p, ellipsoid.getFrame(), null);
return new NormalizedGeodeticPoint(gp.getLatitude(), gp.getLongitude(), gp.getAltitude(), 0.0); return new NormalizedGeodeticPoint(gp.getLatitude(), gp.getLongitude(), gp.getAltitude(), 0.0);
...@@ -62,6 +65,7 @@ public class ConstantElevationAlgorithm implements IntersectionAlgorithm { ...@@ -62,6 +65,7 @@ public class ConstantElevationAlgorithm implements IntersectionAlgorithm {
final NormalizedGeodeticPoint closeGuess) final NormalizedGeodeticPoint closeGuess)
throws RuggedException { throws RuggedException {
try { try {
DumpManager.dumpAlgorithm(AlgorithmId.CONSTANT_ELEVATION_OVER_ELLIPSOID, constantElevation);
final Vector3D p = ellipsoid.pointAtAltitude(position, los, constantElevation); final Vector3D p = ellipsoid.pointAtAltitude(position, los, constantElevation);
final GeodeticPoint gp = ellipsoid.transform(p, ellipsoid.getFrame(), null); final GeodeticPoint gp = ellipsoid.transform(p, ellipsoid.getFrame(), null);
return new NormalizedGeodeticPoint(gp.getLatitude(), gp.getLongitude(), gp.getAltitude(), return new NormalizedGeodeticPoint(gp.getLatitude(), gp.getLongitude(), gp.getAltitude(),
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
package org.orekit.rugged.intersection; package org.orekit.rugged.intersection;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.orekit.rugged.api.AlgorithmId;
import org.orekit.rugged.errors.DumpManager;
import org.orekit.rugged.errors.RuggedException; import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.utils.ExtendedEllipsoid; import org.orekit.rugged.utils.ExtendedEllipsoid;
import org.orekit.rugged.utils.NormalizedGeodeticPoint; import org.orekit.rugged.utils.NormalizedGeodeticPoint;
...@@ -39,6 +41,7 @@ public class IgnoreDEMAlgorithm implements IntersectionAlgorithm { ...@@ -39,6 +41,7 @@ public class IgnoreDEMAlgorithm implements IntersectionAlgorithm {
public NormalizedGeodeticPoint intersection(final ExtendedEllipsoid ellipsoid, public NormalizedGeodeticPoint intersection(final ExtendedEllipsoid ellipsoid,
final Vector3D position, final Vector3D los) final Vector3D position, final Vector3D los)
throws RuggedException { throws RuggedException {
DumpManager.dumpAlgorithm(AlgorithmId.IGNORE_DEM_USE_ELLIPSOID);
return ellipsoid.pointOnGround(position, los, 0.0); return ellipsoid.pointOnGround(position, los, 0.0);
} }
...@@ -48,6 +51,7 @@ public class IgnoreDEMAlgorithm implements IntersectionAlgorithm { ...@@ -48,6 +51,7 @@ public class IgnoreDEMAlgorithm implements IntersectionAlgorithm {
final Vector3D position, final Vector3D los, final Vector3D position, final Vector3D los,
final NormalizedGeodeticPoint closeGuess) final NormalizedGeodeticPoint closeGuess)
throws RuggedException { throws RuggedException {
DumpManager.dumpAlgorithm(AlgorithmId.IGNORE_DEM_USE_ELLIPSOID);
return intersection(ellipsoid, position, los); return intersection(ellipsoid, position, los);
} }
......
...@@ -20,6 +20,8 @@ import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; ...@@ -20,6 +20,8 @@ import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.FastMath;
import org.orekit.bodies.GeodeticPoint; import org.orekit.bodies.GeodeticPoint;
import org.orekit.errors.OrekitException; import org.orekit.errors.OrekitException;
import org.orekit.rugged.api.AlgorithmId;
import org.orekit.rugged.errors.DumpManager;
import org.orekit.rugged.errors.RuggedException; import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.errors.RuggedMessages; import org.orekit.rugged.errors.RuggedMessages;
import org.orekit.rugged.intersection.IntersectionAlgorithm; import org.orekit.rugged.intersection.IntersectionAlgorithm;
...@@ -71,6 +73,8 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm { ...@@ -71,6 +73,8 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm {
throws RuggedException { throws RuggedException {
try { try {
DumpManager.dumpAlgorithm(flatBody ? AlgorithmId.DUVENHAGE_FLAT_BODY : AlgorithmId.DUVENHAGE);
// compute intersection with ellipsoid // compute intersection with ellipsoid
final NormalizedGeodeticPoint gp0 = ellipsoid.pointOnGround(position, los, 0.0); final NormalizedGeodeticPoint gp0 = ellipsoid.pointOnGround(position, los, 0.0);
...@@ -161,6 +165,9 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm { ...@@ -161,6 +165,9 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm {
final NormalizedGeodeticPoint closeGuess) final NormalizedGeodeticPoint closeGuess)
throws RuggedException { throws RuggedException {
try { try {
DumpManager.dumpAlgorithm(flatBody ? AlgorithmId.DUVENHAGE_FLAT_BODY : AlgorithmId.DUVENHAGE);
if (flatBody) { if (flatBody) {
// under the (bad) flat-body assumption, the reference point must remain // under the (bad) flat-body assumption, the reference point must remain
// at DEM entry and exit, even if we already have a much better close guess :-( // at DEM entry and exit, even if we already have a much better close guess :-(
......
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