From 2685dd1bd90c77c898b42bd8d71209dbe840ce37 Mon Sep 17 00:00:00 2001 From: drnextgis Date: Tue, 19 Jul 2016 11:34:44 +0700 Subject: [PATCH] Parse MVT id property --- src/ol/format/mvtformat.js | 2 ++ test/spec/ol/format/mvtformat.test.js | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/ol/format/mvtformat.js b/src/ol/format/mvtformat.js index 4eef126ebf..51e31f5a0e 100644 --- a/src/ol/format/mvtformat.js +++ b/src/ol/format/mvtformat.js @@ -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; diff --git a/test/spec/ol/format/mvtformat.test.js b/test/spec/ol/format/mvtformat.test.js index 9f4c8b0015..eb2dc006a7 100644 --- a/test/spec/ol/format/mvtformat.test.js +++ b/test/spec/ol/format/mvtformat.test.js @@ -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); + }); + }); });