Offset coordinates for Clipper to keep them positive.

Limit very high or low latitudes and longitudes.
This commit is contained in:
Eric Fischer
2015-12-08 16:24:17 -08:00
parent bbcf9e1b3c
commit dace304182
2 changed files with 29 additions and 10 deletions
+17
View File
@@ -3,6 +3,23 @@
// http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
void latlon2tile(double lat, double lon, int zoom, long long *x, long long *y) {
// Must limit latitude somewhere to prevent overflow.
// 89.9 degrees latitude is 0.621 worlds beyond the edge of the flat earth,
// hopefully far enough out that there are few expectations about the shape.
if (lat < -89.9) {
lat = -89.9;
}
if (lat > 89.9) {
lat = 89.9;
}
if (lon < -360) {
lon = -360;
}
if (lon > 360) {
lon = 360;
}
double lat_rad = lat * M_PI / 180;
unsigned long long n = 1LL << zoom;