Created
June 8, 2014 18:55
-
-
Save aaronlidman/1ad027043842b0e687ae to your computer and use it in GitHub Desktop.
Generate some points from tile centroids
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
var sm = new (require('sphericalmercator')); | |
var bbox = [ | |
-74.11847034659208, | |
40.65030727676827, | |
-73.88125841625703, | |
40.82946563333333 | |
]; | |
var zoom = 16; | |
var bounds = sm.xyz(bbox, zoom); | |
var count = 0; | |
var features = []; | |
var row = bounds.minX; | |
while (row + 1 <= bounds.maxX + 1) { | |
var column = bounds.minY; | |
while (column + 1 <= bounds.maxY + 1) { | |
var bbox = sm.bbox(row, column, zoom); | |
var centroid = { | |
"type": "Feature", | |
"properties": {}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
bbox[0] + (bbox[2] - bbox[0]), | |
bbox[1] + (bbox[3] - bbox[1]) | |
] | |
} | |
}; | |
features.push(centroid); | |
count++; | |
column++; | |
} | |
row++; | |
} | |
console.log(JSON.stringify(features)); | |
console.log(count); | |
console.log(bounds); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment