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

Added getLatitudeIndex and getLongitudeIndex in Tile.

parent e01a1d43
No related branches found
No related tags found
No related merge requests found
...@@ -183,11 +183,23 @@ public class SimpleTile implements Tile { ...@@ -183,11 +183,23 @@ public class SimpleTile implements Tile {
return elevations[latitudeIndex * getLongitudeColumns() + longitudeIndex]; return elevations[latitudeIndex * getLongitudeColumns() + longitudeIndex];
} }
/** {@inheritDoc} */
@Override
public int getLatitudeIndex(double latitude) {
return (int) FastMath.floor((latitude - minLatitude) / latitudeStep);
}
/** {@inheritDoc} */
@Override
public int getLontitudeIndex(double longitude) {
return (int) FastMath.floor((longitude - minLongitude) / longitudeStep);
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public Location getLocation(final double latitude, final double longitude) { public Location getLocation(final double latitude, final double longitude) {
final int latitudeIndex = (int) FastMath.floor((latitude - minLatitude) / latitudeStep); final int latitudeIndex = getLatitudeIndex(latitude);
final int longitudeIndex = (int) FastMath.floor((longitude - minLongitude) / longitudeStep); final int longitudeIndex = getLontitudeIndex(longitude);
if (longitudeIndex < 0) { if (longitudeIndex < 0) {
if (latitudeIndex < 0) { if (latitudeIndex < 0) {
return Location.SOUTH_WEST; return Location.SOUTH_WEST;
......
...@@ -83,6 +83,18 @@ public interface Tile extends UpdatableTile { ...@@ -83,6 +83,18 @@ public interface Tile extends UpdatableTile {
*/ */
int getLongitudeColumns(); int getLongitudeColumns();
/** Get the latitude index of a point.
* @param latitude geodetic latitude
* @return latirute index (it may lie outside of the tile!)
*/
int getLatitudeIndex(double latitude);
/** Get the longitude index of a point.
* @param longitude geodetic latitude
* @return longitude index (it may lie outside of the tile!)
*/
int getLontitudeIndex(double longitude);
/** Get the minimum elevation in the tile. /** Get the minimum elevation in the tile.
* @return minimum elevation in the tile * @return minimum elevation in the tile
*/ */
......
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