Skip to content

Instantly share code, notes, and snippets.

@aaronlidman
Created June 8, 2014 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronlidman/1ad027043842b0e687ae to your computer and use it in GitHub Desktop.
Save aaronlidman/1ad027043842b0e687ae to your computer and use it in GitHub Desktop.
Generate some points from tile centroids
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