round geometry to centimeter precision
This commit is contained in:
parent
9bfa37271c
commit
1316f6e481
4 changed files with 15 additions and 8 deletions
|
@ -33,8 +33,15 @@ def json_encoder_reindent(method, data, *args, **kwargs):
|
|||
return result.replace(b'"'+magic_marker, b'').replace(magic_marker+b'"', b'')
|
||||
|
||||
|
||||
def sort_geojson(data):
|
||||
def format_geojson(data, round=True):
|
||||
return OrderedDict((
|
||||
('type', data['type']),
|
||||
('coordinates', data['coordinates']),
|
||||
('coordinates', round_coordinates(data['coordinates']) if round else data['coordinates']),
|
||||
))
|
||||
|
||||
|
||||
def round_coordinates(data):
|
||||
if isinstance(data, (list, tuple)):
|
||||
return tuple(round_coordinates(item) for item in data)
|
||||
else:
|
||||
return round(data, 2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue