fix street numbers geographical coords reading (#8238)
This commit is contained in:
parent
b1aa0db213
commit
19672529ae
|
@ -128,6 +128,18 @@ class VoiesView(View, SingleObjectMixin):
|
|||
|
||||
|
||||
class VoiesCommuneView(View, SingleObjectMixin):
|
||||
"""
|
||||
Called service
|
||||
$ curl .../adresse/rest/commune/34057/voie/ALL DES CONDAMINES/numero
|
||||
Expected result when called with no street number:
|
||||
[{"attributes": {"nom_voie": "ALL DES CONDAMINES", "numero": 8}, ...]
|
||||
When called with street number:
|
||||
$ curl .../adresse/rest/commune/34057/voie/ALL DES CONDAMINES/numero/8
|
||||
Expected result:
|
||||
[{"geometry": {"y": 6281724.800000001, "x": 773304.5},
|
||||
"attributes": {"numero": 8, "nom_voie": "ALL DES CONDAMINES"}},
|
||||
...]
|
||||
"""
|
||||
model = MontpellierSig
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -140,9 +152,11 @@ class VoiesCommuneView(View, SingleObjectMixin):
|
|||
voies_communes = []
|
||||
for i in result:
|
||||
attrs = i['attributes']
|
||||
voies_communes.append({'id': '%(numero)s %(nom_voie)s' % attrs,
|
||||
'text': '%(numero)s %(nom_voie)s' % attrs,
|
||||
'x': attrs['x'], 'y': attrs['y']})
|
||||
voie = {'id': '%(numero)s %(nom_voie)s' % attrs,
|
||||
'text': '%(numero)s %(nom_voie)s' % attrs}
|
||||
if i.get('geometry'):
|
||||
voie.update({'x': i['geometry'].get('x'), 'y': i['geometry'].get('y')})
|
||||
voies_communes.append(voie)
|
||||
voies_communes.sort(lambda x, y: cmp(x['id'], y['id']))
|
||||
return utils.response_for_json(request, {'data': voies_communes})
|
||||
|
||||
|
|
Loading…
Reference in New Issue