Parse MVT id property

This commit is contained in:
drnextgis
2016-07-19 11:34:44 +07:00
parent 8a0f18de56
commit 2685dd1bd9
2 changed files with 11 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);
});
});
});