mirror of
https://github.com/mapbox/vector-tile-js.git
synced 2026-02-01 14:32:53 +00:00
Make VectorTileFeature#id a public property
This commit is contained in:
parent
91b1349853
commit
5c453951e1
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user