Merge pull request #3784 from fredj/geojson_geometry
Always write the GeoJSONFeature geometry property
This commit is contained in:
@@ -123,7 +123,7 @@ var GeoJSONFeature = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {GeoJSONGeometry}
|
||||
* @type {GeoJSONGeometry|GeoJSONGeometryCollection}
|
||||
*/
|
||||
GeoJSONFeature.prototype.geometry;
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user