Created
July 4, 2017 14:59
-
-
Save javisantana/06d6c42a33ddac56b6ae8acd458a7e76 to your computer and use it in GitHub Desktop.
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 characters
// license: BSD3 | |
const WEBMERCATOR_R = 6378137.0; | |
const DIAMETER = WEBMERCATOR_R * 2 * Math.PI; | |
class Mercator { | |
static project(lon, lat) { | |
var x = DIAMETER * lon/360.0; | |
var sinlat = Math.sin(lat * Math.PI/180.0); | |
var y = DIAMETER *Math.log((1+sinlat)/(1-sinlat)) / (4*Math.PI); | |
return { x, y }; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment