Be more consistent about when longitudes beyond 180 are allowed

This commit is contained in:
Eric Fischer
2019-04-12 12:12:14 -07:00
parent b147ff22b1
commit 4d3e30773f
6 changed files with 44 additions and 7 deletions
+8 -3
View File
@@ -22,12 +22,17 @@ void lonlat2tile(double lon, double lat, int zoom, long long *x, long long *y) {
int lat_class = fpclassify(lat);
int lon_class = fpclassify(lon);
bool bad_lon = false;
if (lat_class == FP_INFINITE || lat_class == FP_NAN) {
lat = 89.9;
}
if (lon_class == FP_INFINITE || lon_class == FP_NAN) {
lon = 360;
// Keep these far enough from the plane that they don't get
// moved back into it by 360-degree offsetting
lon = 720;
bad_lon = true;
}
// Must limit latitude somewhere to prevent overflow.
@@ -40,10 +45,10 @@ void lonlat2tile(double lon, double lat, int zoom, long long *x, long long *y) {
lat = 89.9;
}
if (lon < -360) {
if (lon < -360 && !bad_lon) {
lon = -360;
}
if (lon > 360) {
if (lon > 360 && !bad_lon) {
lon = 360;
}