Skip to content
Snippets Groups Projects
Commit 304a7b36 authored by Guylaine Prat's avatar Guylaine Prat
Browse files

Improve the way the dump is supended and resumed in case of nesting

Issue #377
In case the dump is already suspended, the resume stage is dealt
correctly
parent df494bfa
No related branches found
No related tags found
No related merge requests found
......@@ -706,11 +706,17 @@ public class Rugged {
// ==================
// Initialization
// --------------
// Deactivate the dump because no need to keep intermediate computations of inverse loc (can be regenerate)
final Boolean wasSuspended = DumpManager.suspend();
// compute the sensor pixel on the desired ground point WITHOUT atmosphere
atmosphericRefraction.deactivateComputation();
final SensorPixel sp0 = inverseLocation(sensorName, point, minLine, maxLine);
atmosphericRefraction.reactivateComputation();
// Reactivate the dump
DumpManager.resume(wasSuspended);
if (sp0 == null) {
// Impossible to find the point in the given min line and max line (without atmosphere)
throw new RuggedException(RuggedMessages.INVALID_RANGE_FOR_LINES, minLine, maxLine, "");
......@@ -746,6 +752,8 @@ public class Rugged {
}
// The sensor pixel is found !
final SensorPixel sensorPixelWithAtmosphere = new SensorPixel(corrLinePrevious, corrPixelPrevious);
// Dump the found sensorPixel
DumpManager.dumpInverseLocationResult(sensorPixelWithAtmosphere);
return sensorPixelWithAtmosphere;
......@@ -766,6 +774,9 @@ public class Rugged {
final int nbPixelGrid, final int nbLineGrid,
final LineSensor sensor, final int minLine, final int maxLine) {
// Deactivate the dump because no need to keep intermediate computations of inverse loc (can be regenerate)
final Boolean wasSuspended = DumpManager.suspend();
final SensorPixel[][] sensorPixelGrid = new SensorPixel[nbPixelGrid][nbLineGrid];
final String sensorName = sensor.getName();
......@@ -804,6 +815,9 @@ public class Rugged {
} // end loop vIndex
} // end loop uIndex
// Reactivate the dump
DumpManager.resume(wasSuspended);
// The sensor grid computed WITHOUT atmospheric refraction correction
return sensorPixelGrid;
}
......@@ -819,6 +833,9 @@ public class Rugged {
private GeodeticPoint[][] computeDirectLocOnGridWithAtmosphere(final double[] pixelGrid, final double[] lineGrid,
final LineSensor sensor) {
// Deactivate the dump because no need to keep intermediate computations of direct loc (can be regenerate)
final Boolean wasSuspended = DumpManager.suspend();
final int nbPixelGrid = pixelGrid.length;
final int nbLineGrid = lineGrid.length;
final GeodeticPoint[][] groundGridWithAtmosphere = new GeodeticPoint[nbPixelGrid][nbLineGrid];
......@@ -840,6 +857,9 @@ public class Rugged {
} // end loop vIndex
} // end loop uIndex
// Reactivate the dump
DumpManager.resume(wasSuspended);
// The ground grid computed WITH atmospheric refraction correction
return groundGridWithAtmosphere;
}
......
......@@ -86,15 +86,25 @@ 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.
*/
public static void suspend() {
isSuspended = true;
public static Boolean suspend() {
// Check if the dump is already suspended
if (isSuspended) {
return isSuspended;
} else {
isSuspended = true;
return false;
}
}
/** Resume the dump.
/** Resume the dump, only if it was not already suspended.
*/
public static void resume() {
isSuspended = false;
public static void resume(Boolean wasSuspended) {
if (!wasSuspended) {
isSuspended = false;
}
}
/** Check if dump is active for this thread.
......
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