Created
June 9, 2016 05:32
-
-
Save anandthakker/18b72959b1eb65f4d1b177e02649862a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var tb = require('tilebelt') | |
var turf = require('turf') | |
var columns = ['Zoom', 'Tile size at equator (km)', 'Resolution at equator (m)'] | |
console.log(columns.join('|')) | |
console.log(columns.map((c) => c.replace(/./g, '-')).join('|')) | |
for (var z = 0; z < 22; z++) { | |
var tile = tb.tileToGeoJSON(tb.pointToTile(0, 0, z)); | |
var area = turf.area(tile); | |
console.log([ | |
z, | |
format(Math.sqrt(area) / 1000), | |
format(Math.sqrt((area / (256 * 256)))) | |
].join('|')) | |
} | |
function format (num) { | |
return num < 2 ? num.toFixed(2) : Math.round(num) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment