Created
July 2, 2015 07:24
-
-
Save donSchoe/f12fffb3584ee2b9042d to your computer and use it in GitHub Desktop.
Revisions
-
donSchoe created this gist
Jul 2, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ // JavaScript // converts lat/lon to pixel x/y at zoom level 0 for 256*256 tile size , inverts y coord function latLonToPixels(lat, lon) { // lat, lon: epsg:4326 var sinLat = Math.sin(lat * Math.PI / 180.0); var pixelX = ((lon + 180) / 360) * 256; var pixelY = (0.5 - Math.log((1 + sinLat) / (1 - sinLat)) / (Math.PI * 4)) * 256; return { x: pixelX, y: pixelY }; // object with .x and .y }