added state to json info

parent 9132f980
#!/usr/bin/python
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
from catalog.models import Polygon
import json, unicodedata
import math
class Command(BaseCommand):
def handle(self, *args, **options):
pList = Polygon.objects.all()
state_parser = {
'01': "Aguascalientes", '02': "Baja California", '03': "Baja California Sur", '04': "Campeche",
'05': "Coahuila", '06': "Colima", '07': "Chiapas", '08': "Chihuahua",
'09': "Ciudad de México",'10': "Durango", '11': "Guanajuato", '12': "Guerrero",
'13': "Hidalgo", '14': "Jalisco", '15': "México", '16': "Michoacán",
'17': "Morelos", '18': "Nayarit", '19': "Nuevo León", '20': "Oaxaca",
'21': "Puebla", '22': "Querétaro", '23': "Quintana Roo", '24': "San Luis Potosí",
'25': "Sinaloa", '26': "Sonora", '27': "Tabasco", '28': "Tamaulipas",
'29': "Tlaxcala", '30': "Veracruz", '31': "Yucatán", '32': "Zacatecas"
}
for p in pList:
j = json.loads(p.json_info)
j['properties']['ENT_NAME'] = state_parser[j['properties']['CVE_ENT']]
p.json_info = json.dumps(j, ensure_ascii=True)
p.save()
\ No newline at end of file
......@@ -112,17 +112,6 @@ def productList(request):
class SearchSubmitView(View):
template = 'map.html'
# template = 'search_submit.html'
state_parser = {
'01': "Aguascalientes", '02': "Baja California", '03': "Baja California Sur", '04': "Campeche",
'05': "Coahuila", '06': "Colima", '07': "Chiapas", '08': "Chihuahua",
'09': "Ciudad de México",'10': "Durango", '11': "Guanajuato", '12': "Guerrero",
'13': "Hidalgo", '14': "Jalisco", '15': "México", '16': "Michoacán",
'17': "Morelos", '18': "Nayarit", '19': "Nuevo León", '20': "Oaxaca",
'21': "Puebla", '22': "Querétaro", '23': "Quintana Roo", '24': "San Luis Potosí",
'25': "Sinaloa", '26': "Sonora", '27': "Tabasco", '28': "Tamaulipas",
'29': "Tlaxcala", '30': "Veracruz", '31': "Yucatán", '32': "Zacatecas"
}
def strip_accents(self, s):
return ''.join((c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn'))
......@@ -151,7 +140,7 @@ class SearchSubmitView(View):
list.append({
'id': str(polygon.id),
'city': polygonInfo['properties']['NOMGEO'],
'state': self.state_parser[polygonInfo['properties']['CVE_ENT']],
'state': polygonInfo['properties']['ENT_NAME'],
'geojson': polygonInfo,
'wkt_polygon': polygon.wkt_polygon
})
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment