Always write the GeoJSONFeature geometry property

This commit is contained in:
Frederic Junod
2015-06-10 17:50:54 +02:00
parent 4aa3ef59d5
commit d8a495b639
2 changed files with 8 additions and 0 deletions

View File

@@ -541,6 +541,8 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function(
if (goog.isDefAndNotNull(geometry)) {
object['geometry'] =
ol.format.GeoJSON.writeGeometry_(geometry, opt_options);
} else {
object['geometry'] = null;
}
var properties = feature.getProperties();
goog.object.remove(properties, feature.getGeometryName());

View File

@@ -530,6 +530,12 @@ describe('ol.format.GeoJSON', function() {
expect(geojson.properties).to.eql(null);
});
it('writes out a feature without geometry correctly', function() {
var feature = new ol.Feature();
var geojson = format.writeFeatureObject(feature);
expect(geojson.geometry).to.eql(null);
});
});
describe('#writeGeometry', function() {