-
-
Save matallo/ff03af7ac32bb358e8295193e94984f9 to your computer and use it in GitHub Desktop.
This file contains 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