Make VectorTileFeature#id a public property

This commit is contained in:
John Firebaugh 2016-07-18 13:57:47 -07:00
parent 91b1349853
commit 5c453951e1
3 changed files with 6 additions and 3 deletions

View File

@ -93,6 +93,7 @@ An object that contains the data for a single feature.
- **type** (`Number`) — type of the feature (also see `VectorTileFeature.types`)
- **extent** (`Number`) — feature extent size
- **id** (`Number`) — feature identifier, if present
- **properties** (`Object`) — object literal with feature properties
#### Methods

View File

@ -20,7 +20,7 @@ function VectorTileFeature(pbf, end, extent, keys, values) {
}
function readFeature(tag, feature, pbf) {
if (tag == 1) feature._id = pbf.readVarint();
if (tag == 1) feature.id = pbf.readVarint();
else if (tag == 2) readTag(pbf, feature);
else if (tag == 3) feature.type = pbf.readVarint();
else if (tag == 4) feature._geometry = pbf.pos;
@ -185,8 +185,8 @@ VectorTileFeature.prototype.toGeoJSON = function(x, y, z) {
properties: this.properties
};
if ('_id' in this) {
result.id = this._id;
if ('id' in this) {
result.id = this.id;
}
return result;

View File

@ -58,6 +58,8 @@ test('parsing vector tiles', function(t) {
var park = tile.layers.poi_label.feature(1e9);
}, 'throws on reading a feature out of bounds');
t.equal(park.id, 3000003150561);
t.equal(park.properties.name, 'Mauerpark');
t.equal(park.properties.type, 'Park');