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

Added a protection agains out of bounds indices.

parent 878db231
No related branches found
No related tags found
No related merge requests found
......@@ -286,7 +286,10 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm {
cN * entry.getAltitude() + cX * exit.getAltitude(),
tile.getMinimumLongitude());
}
final int crossingLat = tile.getFloorLatitudeIndex(crossingGP.getLatitude());
final int crossingLat =
FastMath.max(0,
FastMath.min(tile.getLatitudeRows() - 1,
tile.getFloorLatitudeIndex(crossingGP.getLatitude())));
// adjust indices as the crossing point is by definition between the sub-tiles
final int crossingLonBefore = crossingLon - (entryLon <= exitLon ? 1 : 0);
......@@ -345,7 +348,10 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm {
cN * entry.getAltitude() + cX * exit.getAltitude(),
tile.getMinimumLongitude());
}
final int crossingLon = tile.getFloorLongitudeIndex(crossingGP.getLongitude());
final int crossingLon =
FastMath.max(0,
FastMath.min(tile.getLongitudeColumns() - 1,
tile.getFloorLongitudeIndex(crossingGP.getLongitude())));
// adjust indices as the crossing point is by definition between the sub-tiles
final int crossingLatBefore = crossingLat - (entryLat <= exitLat ? 1 : 0);
......
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