Forked from spite/gist:051604efd1d971ab4b6ef1bc1ae2636e
Last active
June 25, 2021 11:39
-
-
Save Bigismall/afa5366cc9c65ac3b4594f4580fc4741 to your computer and use it in GitHub Desktop.
zoom - lat -lon to mapzen/tilezen tile
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
function getTileFromLatLon(zoom, lat, lon) { | |
const width = Math.pow(2, zoom); | |
const height = Math.pow(2, zoom); | |
const latRad = (lat * Math.PI) / 180; | |
const x = ~~((width * (lon + 180)) / 360); | |
const y = ~~(((1 - Math.asinh(Math.tan(latRad)) / Math.PI) / 2.0) * height); | |
return {zoom, x, y}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://registry.opendata.aws/terrain-tiles/