From 77b451f2c8f6cd8e4e4e138d83e29aa5e4791b0d Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 12 Oct 2015 12:51:55 -0700 Subject: [PATCH] Fix some rounding error just by staying in double precision --- projection.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projection.c b/projection.c index e554cfd..effb347 100644 --- a/projection.c +++ b/projection.c @@ -37,8 +37,7 @@ void latlon2tile(double lat, double lon, int zoom, unsigned int *x, unsigned int void tile2latlon(unsigned int x, unsigned int y, int zoom, double *lat, double *lon) { unsigned long long n = 1LL << zoom; *lon = 360.0 * x / n - 180.0; - float lat_rad = atan(sinh(M_PI * (1 - 2.0 * y / n))); - *lat = lat_rad * 180 / M_PI; + *lat = atan(sinh(M_PI * (1 - 2.0 * y / n))) * 180.0 / M_PI; } unsigned long long encode(unsigned int wx, unsigned int wy) {