Tiles Arithmetic

16 views
Skip to first unread message

Arnie Shore

unread,
Apr 24, 2016, 10:49:32 AM4/24/16
to leafl...@googlegroups.com
All, not really a Leaflet question per se, but I've been struggling with this.  (Dr. Google wasn't her usual help.)

Given a pair of WMS tile numbers, what's the javascript for computing the bounding box coordinate pairs?

Arnie Shore

unread,
Apr 24, 2016, 8:38:14 PM4/24/16
to leafl...@googlegroups.com
Shifting the emphasis a bit: what do I need to revise in the following php functions to return the coordinates of the south-east corner, given that they now return the (standard) north-west coordinates?

function num2lat ($zoom, $num) {
    $n = pow(2, $zoom);
    $lat_deg = rad2deg(atan(sinh(pi() * (1 - 2 * $num / $n))));
    return $lat_deg;
    }
function num2long ($zoom, $num) {
    $n = pow(2, $zoom);
    $lon_deg = $num / $n * 360.0 - 180.0;
    return $lon_deg;
    }


Reply all
Reply to author
Forward
0 new messages