Encode ol.geom.Circles as empty geometry collections in GeoJSON

GeoJSON does not support circles, nor null geometries.  Empty geometry
collections seem to be the way to represent at null geometry in GeoJSON.
This commit is contained in:
Tom Payne
2014-01-13 12:45:45 +01:00
parent 5886d0dec0
commit 99eca3037d
2 changed files with 26 additions and 1 deletions

View File

@@ -458,6 +458,16 @@ describe('ol.format.GeoJSON', function() {
expect(geometries[i].getCoordinates()).
to.eql(gotGeometries[i].getCoordinates());
}
});
it('encodes a circle as an empty geometry collection', function() {
var circle = new ol.geom.Circle([0, 0], 1);
var geojson = format.writeGeometry(circle);
expect(geojson).to.eql({
'type': 'GeometryCollection',
'geometries': []
});
});
});
@@ -468,6 +478,7 @@ describe('ol.format.GeoJSON', function() {
goog.require('ol.Feature');
goog.require('ol.extent');
goog.require('ol.format.GeoJSON');
goog.require('ol.geom.Circle');
goog.require('ol.geom.GeometryCollection');
goog.require('ol.geom.LineString');
goog.require('ol.geom.LinearRing');