From f0bf61bbf30e8341e75df8c661defa7c7e9c5c44 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Thu, 4 Dec 2014 11:23:01 +0100 Subject: [PATCH] Do not encode geometry in properties if geometryName is different --- src/ol/format/geojsonformat.js | 2 +- test/spec/ol/format/geojsonformat.test.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ol/format/geojsonformat.js b/src/ol/format/geojsonformat.js index 098cb7fffd..0ca12944f1 100644 --- a/src/ol/format/geojsonformat.js +++ b/src/ol/format/geojsonformat.js @@ -508,7 +508,7 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function( ol.format.GeoJSON.writeGeometry_(geometry, opt_options)); } var properties = feature.getProperties(); - goog.object.remove(properties, 'geometry'); + goog.object.remove(properties, feature.getGeometryName()); if (!goog.object.isEmpty(properties)) { goog.object.set(object, 'properties', properties); } diff --git a/test/spec/ol/format/geojsonformat.test.js b/test/spec/ol/format/geojsonformat.test.js index a3da003c8f..370523d575 100644 --- a/test/spec/ol/format/geojsonformat.test.js +++ b/test/spec/ol/format/geojsonformat.test.js @@ -498,6 +498,15 @@ describe('ol.format.GeoJSON', function() { } }); + it('writes out a feature with a different geometryName correctly', + function() { + var feature = new ol.Feature({'foo': 'bar'}); + feature.setGeometryName('mygeom'); + feature.setGeometry(new ol.geom.Point([5, 10])); + var geojson = format.writeFeatures([feature]); + expect(geojson.features[0].properties.mygeom).to.eql(undefined); + }); + }); describe('#writeGeometry', function() {