fix format_geojson to work with GeometryCollections / MultiPolygons
@@ -34,10 +34,16 @@ def json_encoder_reindent(method, data, *args, **kwargs):
def format_geojson(data, round=True):
+ coordinates = data.get('coordinates', None)
+ if coordinates is not None:
return OrderedDict((
('type', data['type']),
('coordinates', round_coordinates(data['coordinates']) if round else data['coordinates']),
))
+ return OrderedDict((
+ ('type', data['type']),
+ ('geometries', [format_geojson(geometry, round=round) for geometry in data['geometries']]),
+ ))
def round_coordinates(data):
