-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,3 +125,36 @@ VectorTileFeature.prototype.bbox = function() { | |
|
||
return [x1, y1, x2, y2]; | ||
}; | ||
|
||
var SphericalMercator = require('sphericalmercator'); | ||
|
||
VectorTileFeature.prototype.toGeoJSON = function(x, y, z) { | ||
var merc = new SphericalMercator({size: this.extent}), | ||
x0 = this.extent * x, | ||
y0 = this.extent * y, | ||
coords = this.loadGeometry(), | ||
type = VectorTileFeature.types[this.type]; | ||
|
||
for (var i = 0; i < coords.length; i++) { | ||
var line = coords[i]; | ||
for (var j = 0; j < line.length; j++) { | ||
var p = line[j]; | ||
line[j] = merc.ll([p.x + x0, p.y + y0], z); | ||
} | ||
} | ||
|
||
if (type === 'Point') { | ||
coords = coords[0][0]; | ||
} else if (type === 'LineString') { | ||
coords = coords[0]; | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jfirebaugh
Author
Contributor
|
||
|
||
return { | ||
type: "Feature", | ||
geometry: { | ||
type: type, | ||
coordinates: coords | ||
}, | ||
properties: this.properties | ||
}; | ||
}; |
This will be broken in many cases — do we intentionally keep it simple until we can fully reconstruct GeoJSON after mapnik-vector-tile changes?