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

Delegate final pixel intersection to Tile.

parent d823d636
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,7 @@ import org.orekit.rugged.core.raster.IntersectionAlgorithm;
import org.orekit.rugged.core.raster.Tile;
import org.orekit.rugged.core.raster.TilesCache;
/** Digital Elevation Model intersection using Duvenhage's algorithm.
/** Digital Elevation Model intersection using Bernardt Duvenhage's algorithm.
* <p>
* The algorithm is described in the 2009 paper:
* <a href="http://researchspace.csir.co.za/dspace/bitstream/10204/3041/1/Duvenhage_2009.pdf">Using
......@@ -55,8 +55,7 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm {
/** {@inheritDoc} */
@Override
public void setUpTilesManagement(final TileUpdater updater, final int maxCachedTiles) {
cache = new TilesCache<MinMaxTreeTile>(new MinMaxTreeTileFactory(),
updater, maxCachedTiles);
cache = new TilesCache<MinMaxTreeTile>(new MinMaxTreeTileFactory(), updater, maxCachedTiles);
}
/** {@inheritDoc} */
......@@ -96,7 +95,7 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm {
while (true) {
int currentLatIndex = tile.getLatitudeIndex(current.getLatitude());
int currentLonIndex = tile.getLontitudeIndex(current.getLongitude());
int currentLonIndex = tile.getLongitudeIndex(current.getLongitude());
// find where line-of-sight exit tile
final LimitPoint exit = findExit(tile, ellipsoid, position, los);
......@@ -107,13 +106,13 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm {
final GeodeticPoint next = lineOfSightQueue.remove(lineOfSightQueue.size() - 1);
final int nextLatIndex = tile.getLatitudeIndex(next.getLatitude());
final int nextLonIndex = tile.getLontitudeIndex(next.getLongitude());
final int nextLonIndex = tile.getLongitudeIndex(next.getLongitude());
if (FastMath.abs(currentLatIndex - nextLatIndex) <= 1 &&
FastMath.abs(currentLonIndex - nextLonIndex) <= 1) {
// we have narrowed the search down to a single Digital Elevation Model pixel
final GeodeticPoint intersection = pixelIntersection(ellipsoid, current, next,
tile, nextLatIndex, nextLonIndex);
final GeodeticPoint intersection =
tile.pixelIntersection(ellipsoid, current, next, nextLatIndex, nextLonIndex);
if (intersection != null) {
return intersection;
} else {
......@@ -237,42 +236,6 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm {
}
/** Find the intersection of a line-of-sight and a Digital Elevation Model pixel.
* @param ellipsoid reference ellipsoid
* @param pA first point on the line (close to the pixel)
* @param pB second point on the line (close to the pixel)
* @param tile Digital Elevation Model tile
* @param latitudeIndex latitude index of the Digital Elevation Model pixel
* @param longitudeIndex longitude index of the Digital Elevation Model pixel
* @return point corresponding to line-of-sight crossing the Digital Elevation Model surface
* if it lies within the pixel, null otherwise
* @exception RuggedException if intersection point cannot be computed
* @exception OrekitException if intersection point cannot be converted to geodetic coordinates
*/
private GeodeticPoint pixelIntersection(final ExtendedEllipsoid ellipsoid, final GeodeticPoint pA, final GeodeticPoint pB,
final MinMaxTreeTile tile, final int latitudeIndex, final int longitudeIndex)
throws RuggedException, OrekitException {
// Digital Elevation Mode coordinates at pixel vertices
final double x00 = tile.getLongitudeAtIndex(longitudeIndex);
final double y00 = tile.getLatitudeAtIndex(latitudeIndex);
final double z00 = tile.getElevationAtIndices(latitudeIndex, longitudeIndex);
final double z01 = tile.getElevationAtIndices(latitudeIndex + 1, longitudeIndex);
final double z10 = tile.getElevationAtIndices(latitudeIndex, longitudeIndex + 1);
final double z11 = tile.getElevationAtIndices(latitudeIndex + 1, longitudeIndex + 1);
// line-of-sight coordinates at close points
final double dxA = (pA.getLongitude() - x00) / tile.getLongitudeStep();
final double dyA = (pA.getLatitude() - y00) / tile.getLatitudeStep();
final double dzA = pA.getAltitude();
final double dxB = (pB.getLongitude() - x00) / tile.getLongitudeStep();
final double dyB = (pB.getLatitude() - y00) / tile.getLatitudeStep();
final double dzB = pB.getAltitude();
// TODO: compute intersection
return null;
}
/** Compute a line-of-sight exit point from a tile.
* @param tile tile to consider
* @param ellipsoid reference ellipsoid
......
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