fix format_geojson to work with GeometryCollections / MultiPolygons
This commit is contained in:
parent
c65f01d620
commit
c051b3b536
1 changed files with 7 additions and 1 deletions
|
@ -34,10 +34,16 @@ def json_encoder_reindent(method, data, *args, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def format_geojson(data, round=True):
|
def format_geojson(data, round=True):
|
||||||
|
coordinates = data.get('coordinates', None)
|
||||||
|
if coordinates is not None:
|
||||||
return OrderedDict((
|
return OrderedDict((
|
||||||
('type', data['type']),
|
('type', data['type']),
|
||||||
('coordinates', round_coordinates(data['coordinates']) if round else data['coordinates']),
|
('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):
|
def round_coordinates(data):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue