Skip to content

Instantly share code, notes, and snippets.

@kamataryo

kamataryo/calc.js

Last active Jul 5, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.