Commit 7b9b3c7f authored by Guylaine Prat's avatar Guylaine Prat
Browse files

"zipper tile" with DEM without same resolution between tiles

Done:
Algorithm for tiles with change in resolution between North/South edge
of tiles. No change of resolution taken into account between West/East
edge of tiles as known DEM does not have such change.
Algorithm done also for corner zipper tiles.
Test with dummy SRTM
To be done:
Test with real data from SRTM
parent 04ca8514
Pipeline #2705 passed with stage
in 4 minutes and 17 seconds
......@@ -434,7 +434,7 @@ public class SimpleTile implements Tile {
* @param latitude geodetic latitude (rad)
* @return latitude index (it may lie outside of the tile!)
*/
private double getDoubleLatitudeIndex(final double latitude) {
protected double getDoubleLatitudeIndex(final double latitude) {
return (latitude - minLatitude) / latitudeStep;
}
......@@ -442,7 +442,7 @@ public class SimpleTile implements Tile {
* @param longitude geodetic longitude (rad)
* @return longitude index (it may lie outside of the tile!)
*/
private double getDoubleLongitudeIndex(final double longitude) {
protected double getDoubleLongitudeIndex(final double longitude) {
return (longitude - minLongitude) / longitudeStep;
}
......@@ -477,52 +477,4 @@ public class SimpleTile implements Tile {
}
}
}
/** {@inheritDoc}
* @sinceX.x
*/
@Override
public Location checkNeighborhood(double latitude, double longitude) {
// TODO GP check if useful ...
final int latitudeIndex = getFloorLatitudeIndex(latitude);
final int longitudeIndex = getFloorLongitudeIndex(longitude);
System.out.format(">>> Index lat = " + latitudeIndex + " long = " + longitudeIndex + " ");
if (longitudeIndex < 1) {
if (latitudeIndex < 1) {
System.out.println(Location.SOUTH_WEST + "\n");
return Location.SOUTH_WEST;
} else if (latitudeIndex <= (latitudeRows - 2)) {
System.out.println(Location.WEST + "\n");
return Location.WEST;
} else {
System.out.println(Location.NORTH_WEST + "\n");
return Location.NORTH_WEST;
}
} else if (longitudeIndex <= (longitudeColumns - 2)) {
if (latitudeIndex < 1) {
System.out.println(Location.SOUTH + "\n");
return Location.SOUTH;
} else if (latitudeIndex <= (latitudeRows - 2)) {
System.out.println(Location.HAS_INTERPOLATION_NEIGHBORS + "\n");
return Location.HAS_INTERPOLATION_NEIGHBORS;
} else {
System.out.println(Location.NORTH + "\n");
return Location.NORTH;
}
} else {
if (latitudeIndex < 1) {
System.out.println(Location.SOUTH_EAST + "\n");
return Location.SOUTH_EAST;
} else if (latitudeIndex <= (latitudeRows - 2)) {
System.out.println(Location.EAST + "\n");
return Location.EAST;
} else {
System.out.println(Location.NORTH_EAST + "\n");
return Location.NORTH_EAST;
}
}
}
}
......@@ -280,25 +280,10 @@ public interface Tile extends UpdatableTile {
int latitudeIndex, int longitudeIndex);
/** Check if a tile covers a ground point.
* <p>
* TBN: used by intersection algorithms. Supposed tiles are overlapping.
* </p>
* @param latitude ground point latitude
* @param longitude ground point longitude
* @return location of the ground point with respect to tile
*/
Location getLocation(double latitude, double longitude);
// TODO GP check if useful ...
/** Get tile neighborhood (in case the DEM tiles are not overlapping).
* <p>
* TBN: used to create zipper tiles in case of DEM with tiles not overlapping.
* </p>
* @param latitude ground point latitude
* @param longitude ground point longitude
* @return location of the tile vs the neighborhood
* @since X.x
*/
Location checkNeighborhood(double latitude, double longitude);
}
......@@ -7,6 +7,7 @@ import org.hipparchus.util.MathUtils;
* To simulate DEM SRTM3 V4.0 tiles (without the real data !)
* The tiles are seamless = no overlapping
*
* @author Guylaine Prat
*/
public class DummySRTMsimpleElevationUpdater implements TileUpdater {
......@@ -45,6 +46,19 @@ public class DummySRTMsimpleElevationUpdater implements TileUpdater {
*/
public void updateTile(final double latitude, final double longitude, UpdatableTile tile) {
int numberOfStep;
// Change the tile step for latitude above 60 degrees and below 60 degrees
if (FastMath.toDegrees(latitude) > 60. || FastMath.toDegrees(latitude) < -60.) {
// step * 3 for latitude > 60 or < -60
this.stepRad = FastMath.toRadians(this.tileSizeDeg*3 / this.n);
numberOfStep = this.n/3;
} else { // step = tile size / n
this.stepRad = FastMath.toRadians(this.tileSizeDeg / this.n);
numberOfStep = this.n;
}
// Get the tile indices that contents the current latitude and longitude
int[] tileIndex = findIndexInTile(latitude, longitude);
double latIndex = tileIndex[0];
......@@ -57,15 +71,15 @@ public class DummySRTMsimpleElevationUpdater implements TileUpdater {
double minLatitude = FastMath.toRadians(60. - latIndex*5.) + 0.5*stepRad;
double minLongitude = FastMath.toRadians(-180. + (lonIndex - 1)*5.) + 0.5*stepRad;
tile.setGeometry(minLatitude, minLongitude, stepRad, stepRad, n, n);
tile.setGeometry(minLatitude, minLongitude, stepRad, stepRad, numberOfStep, numberOfStep);
for (int i = 0; i < n; ++i) {
for (int i = 0; i < numberOfStep; ++i) {
int p = (int) FastMath.floor((FastMath.abs(minLatitude) + i * stepRad) / stepRad);
for (int j = 0; j < n; ++j) {
for (int j = 0; j < numberOfStep; ++j) {
int q = (int) FastMath.floor((FastMath.abs(minLongitude) + j * stepRad) / stepRad);
double factor = FastMath.sin(minLatitude + i*stepRad - (minLongitude + j*stepRad))*
FastMath.cos(minLatitude + i*stepRad + (minLongitude + j*stepRad));
tile.setElevation(i, j, (((p ^ q) & 0x1) == 0) ? factor*lonIndex*elevation1 : factor*latIndex*elevation2);
tile.setElevation(i, j, (((p ^ q) & 0x1) == 0) ? factor*lonIndex*elevation1 + q : factor*latIndex*elevation2 + q*p);
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment