more performance improvements (no ordereddict, directly access geojson)
This commit is contained in:
parent
05dab8acb5
commit
b406cb2d13
4 changed files with 29 additions and 40 deletions
|
@ -1,5 +1,4 @@
|
|||
import json
|
||||
from collections import OrderedDict
|
||||
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
|
||||
|
@ -39,14 +38,14 @@ 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']]),
|
||||
))
|
||||
return {
|
||||
'type': data['type'],
|
||||
'coordinates': round_coordinates(data['coordinates']) if round else data['coordinates'],
|
||||
}
|
||||
return {
|
||||
'type': data['type'],
|
||||
'geometries': [format_geojson(geometry, round=round) for geometry in data['geometries']],
|
||||
}
|
||||
|
||||
|
||||
def round_coordinates(data):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue