Calculate tile size
// $ 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