Skip to content
Permalink
Browse files

#1339 possible fix for random zoom to bounds crash caused by lat/lons…

… past the max bounds of the projection
  • Loading branch information...
spyhunter99 committed May 10, 2019
1 parent 9ed9d5a commit b6ea341a9bc2658011f827f57edeaf3baea51fc8
Showing with 16 additions and 2 deletions.
  1. +16 −2 osmdroid-android/src/main/java/org/osmdroid/views/Projection.java
@@ -659,10 +659,24 @@ private void refresh() {
(mIntrinsicScreenRectProjection.left + mIntrinsicScreenRectProjection.right) / 2,
(mIntrinsicScreenRectProjection.top + mIntrinsicScreenRectProjection.bottom) / 2,
mCurrentCenter);
final IGeoPoint neGeoPoint = fromPixels(
IGeoPoint neGeoPoint = fromPixels(
mIntrinsicScreenRectProjection.right, mIntrinsicScreenRectProjection.top, null, true);
final IGeoPoint swGeoPoint = fromPixels(
final TileSystem tileSystem = org.osmdroid.views.MapView.getTileSystem();
if (neGeoPoint.getLatitude() > tileSystem.getMaxLatitude()) {
neGeoPoint = new GeoPoint(tileSystem.getMaxLatitude(), neGeoPoint.getLongitude());
}
if (neGeoPoint.getLatitude() < tileSystem.getMinLatitude()) {
neGeoPoint = new GeoPoint(tileSystem.getMinLatitude(), neGeoPoint.getLongitude());
}
IGeoPoint swGeoPoint = fromPixels(
mIntrinsicScreenRectProjection.left, mIntrinsicScreenRectProjection.bottom, null, true);
if (swGeoPoint.getLatitude() > tileSystem.getMaxLatitude()) {
swGeoPoint = new GeoPoint(tileSystem.getMaxLatitude(), swGeoPoint.getLongitude());
}
if (swGeoPoint.getLatitude() < tileSystem.getMinLatitude()) {
swGeoPoint = new GeoPoint(tileSystem.getMinLatitude(), swGeoPoint.getLongitude());
}

mBoundingBoxProjection.set(
neGeoPoint.getLatitude(), neGeoPoint.getLongitude(),
swGeoPoint.getLatitude(), swGeoPoint.getLongitude());

0 comments on commit b6ea341

Please sign in to comment.
You can’t perform that action at this time.