Skip to content

Instantly share code, notes, and snippets.

@morganherlocker
Created September 18, 2014 20:34
Show Gist options
  • Select an option

  • Save morganherlocker/91d54c1f8aa725006c38 to your computer and use it in GitHub Desktop.

Select an option

Save morganherlocker/91d54c1f8aa725006c38 to your computer and use it in GitHub Desktop.
var building = {}
building.properties = vt.layers.building.feature(i).properties;
building.geometry = vt.layers.building.feature(i).loadGeometry();
traverse(building.geometry).forEach(function(g){
if(!Array.isArray(g) && typeof g.x === 'number') {
var topLeft = tile;
while(topLeft[2] < zoomEncoding){
topLeft = tilebelt.getChildren(topLeft)[0]
}
var x = topLeft[0] + g.x
var y = topLeft[1] + g.y
var bbox = tilebelt.tileToBBOX([x,y,zoomEncoding])
var lon = (bbox[0] + bbox[2])/2
var lat = (bbox[1] + bbox[3])/2
this.update([lon,lat]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment