Skip to content

Commit 3d15fba

Browse files
committed
Include id in toGeoJSON result
Fixes #40
1 parent a3e6da8 commit 3d15fba

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/vectortilefeature.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,18 @@ VectorTileFeature.prototype.toGeoJSON = function(x, y, z) {
155155
type = 'MultiLineString';
156156
}
157157

158-
return {
158+
var result = {
159159
type: "Feature",
160160
geometry: {
161161
type: type,
162162
coordinates: coords
163163
},
164164
properties: this.properties
165165
};
166+
167+
if ('_id' in this) {
168+
result.id = this._id;
169+
}
170+
171+
return result;
166172
};

test/parse.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ test('parsing vector tiles', function(t) {
7272

7373
var point = tile.layers.poi_label.feature(11).toGeoJSON(8801, 5371, 14);
7474
t.deepEqual(point.type, 'Feature');
75+
t.deepEqual(point.id, 3000003150561);
7576
t.deepEqual(point.properties, {
7677
localrank: 1,
7778
maki: 'park',

0 commit comments

Comments
 (0)