Include id in toGeoJSON result

Fixes #40
This commit is contained in:
John Firebaugh 2015-12-10 10:49:46 -08:00
parent a3e6da8c02
commit 3d15fbae71
2 changed files with 8 additions and 1 deletions

View File

@ -155,7 +155,7 @@ VectorTileFeature.prototype.toGeoJSON = function(x, y, z) {
type = 'MultiLineString';
}
return {
var result = {
type: "Feature",
geometry: {
type: type,
@ -163,4 +163,10 @@ VectorTileFeature.prototype.toGeoJSON = function(x, y, z) {
},
properties: this.properties
};
if ('_id' in this) {
result.id = this._id;
}
return result;
};

View File

@ -72,6 +72,7 @@ test('parsing vector tiles', function(t) {
var point = tile.layers.poi_label.feature(11).toGeoJSON(8801, 5371, 14);
t.deepEqual(point.type, 'Feature');
t.deepEqual(point.id, 3000003150561);
t.deepEqual(point.properties, {
localrank: 1,
maki: 'park',