Last active
July 5, 2020 10:14
-
-
Save kamataryo/4987092fe1975dcf367ad7000858f834 to your computer and use it in GitHub Desktop.
Calculate tile size
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
// $ npm install turf tilebelt # dependencies | |
const turf = require("turf"); | |
const tilebelt = require('tilebelt'); | |
const calc = () => { | |
const lon = 10; | |
for (let z = 1; z < 31; z++) { | |
for (let lat = 0; lat < 90; lat += 10) { | |
const [x, y] = tilebelt.pointToTile(lon, lat, z); | |
const geometry = tilebelt.tileToGeoJSON([x, y, z]); | |
const points = geometry.coordinates[0]; | |
let side1 = turf.distance(points[0], points[1]); | |
let top = turf.distance(points[1], points[2]); | |
let side2 = turf.distance(points[2], points[3]); | |
let bottom = turf.distance(points[3], points[4]); | |
console.log([z, lat, Math.max(bottom, top)].join(",")); | |
} | |
} | |
}; | |
calc(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment