Parse MVT id property
This commit is contained in:
@@ -95,6 +95,7 @@ ol.format.MVT.prototype.getType = function() {
|
||||
ol.format.MVT.prototype.readFeature_ = function(
|
||||
rawFeature, layer, opt_options) {
|
||||
var feature = new this.featureClass_();
|
||||
var id = rawFeature.id;
|
||||
var values = rawFeature.properties;
|
||||
values[this.layerName_] = layer;
|
||||
var geometry = ol.format.Feature.transformWithOptions(
|
||||
@@ -104,6 +105,7 @@ ol.format.MVT.prototype.readFeature_ = function(
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry);
|
||||
values[this.geometryName_] = geometry;
|
||||
}
|
||||
feature.setId(id);
|
||||
feature.setProperties(values);
|
||||
feature.setGeometryName(this.geometryName_);
|
||||
return feature;
|
||||
|
||||
@@ -65,6 +65,15 @@ where('ArrayBuffer').describe('ol.format.MVT', function() {
|
||||
.to.eql([rawGeometry[1][0].x, rawGeometry[1][0].y]);
|
||||
});
|
||||
|
||||
it('parses id property', function() {
|
||||
var format = new ol.format.MVT({
|
||||
featureClass: ol.Feature,
|
||||
layers: ['building']
|
||||
});
|
||||
var features = format.readFeatures(data);
|
||||
expect(features[0].getId()).to.be(2);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user