Changeset eb1c94b in observatorio


Ignore:
Timestamp:
Sep 16, 2014, 9:11:58 AM (10 years ago)
Author:
Ing. Roldan Vargas <rvargas@…>
Branches:
master
Children:
111d622
Parents:
b46c98a
Message:

se agrega validación en la función que determina los nodos a ser georeferenciados en el sistema de información geográfico

File:
1 edited

Legend:

Unmodified
Added
Removed
  • procesos/apps/geocadena/views.py

    r5411a89 reb1c94b  
    197197
    198198    try:
    199         grafo = AGraph(settings.PATH + "/tmp/" + usuario + ".dot")
    200 
    201         nodos = [n for n in grafo.nodes_iter() if n.attr['label'][0] in ['J', 'G', 'V', 'E', 'P']]
     199        grafo = AGraph(settings.PATH + "/tmp/" + str(usuario) + ".dot")
     200
     201        if grafo.get_node(0).attr['label'][0] in ['J', 'G', 'V', 'E', 'P']:
     202            nodos = [n for n in grafo.nodes_iter() if n.attr['label'][0] in ['J', 'G', 'V', 'E', 'P']]
    202203       
    203         for c in nodos:
    204 
    205             nivel = ""
    206             rif = grafo.get_node(c).attr['label'][0:10]
    207             ue = getUE(rif)
    208 
    209             icono = ''
    210             if ue:
    211                 if grafo.get_node(c).attr['color'] == 'darkgreen':
    212                     icono = static('geocadena/imgs/markers/mark_center.png')
    213                     nivel = "C"
    214                 elif grafo.get_node(c).attr['color'] == 'yellow':
    215                     icono = static('geocadena/imgs/markers/mark_down.png')
    216                     nivel = "A"
    217                 elif grafo.get_node(c).attr['color'] == 'dodgerblue':
    218                     icono = static('geocadena/imgs/markers/mark_up.png')
    219                     nivel = "P"
    220 
    221                 nombre = ''
    222                 detalles = ''
    223                 dir = ''
    224                 try:
    225                     if ue.nombre is not None:
    226                         nombre = ue.nombre
    227                     else:
    228                         nombre = ue.razon_social
    229 
     204            for c in nodos:
     205
     206                nivel = ""
     207                rif = grafo.get_node(c).attr['label'][0:10]
     208                ue = getUE(rif)
     209
     210                icono = ''
     211                if ue:
     212                    if grafo.get_node(c).attr['color'] == 'darkgreen':
     213                        icono = static('geocadena/imgs/markers/mark_center.png')
     214                        nivel = "C"
     215                    elif grafo.get_node(c).attr['color'] == 'yellow':
     216                        icono = static('geocadena/imgs/markers/mark_down.png')
     217                        nivel = "A"
     218                    elif grafo.get_node(c).attr['color'] == 'dodgerblue':
     219                        icono = static('geocadena/imgs/markers/mark_up.png')
     220                        nivel = "P"
     221
     222                    nombre = ''
     223                    detalles = ''
     224                    dir = ''
    230225                    try:
    231                         if not ue.ciudad is None:
    232                             detalles += 'Ciudad: %s<br>' % ue.ciudad
    233                         if not ue.dir1 is None:
    234                             dir += "%s. " % ue.dir1
    235                         if not ue.dir2 is None:
    236                             dir += "%s. " % ue.dir2
    237                         if not ue.dir3 is None:
    238                             dir += "%s. " % ue.dir3
    239                         if not ue.dir4 is None:
    240                             dir += "%s. " % ue.dir4
     226                        if ue.nombre is not None:
     227                            nombre = ue.nombre
     228                        else:
     229                            nombre = ue.razon_social
     230
     231                        try:
     232                            if not ue.ciudad is None:
     233                                detalles += 'Ciudad: %s<br>' % ue.ciudad
     234                            if not ue.dir1 is None:
     235                                dir += "%s. " % ue.dir1
     236                            if not ue.dir2 is None:
     237                                dir += "%s. " % ue.dir2
     238                            if not ue.dir3 is None:
     239                                dir += "%s. " % ue.dir3
     240                            if not ue.dir4 is None:
     241                                dir += "%s. " % ue.dir4
     242                        except AttributeError:
     243                            dir += ue.direccion
     244
    241245                    except AttributeError:
     246                        try:
     247                            nombre = ue.nombreestablecimiento
     248                        except AttributeError:
     249                            nombre = ue.nombre_comercial
    242250                        dir += ue.direccion
    243251
    244                 except AttributeError:
     252                    if dir.__len__() > 11:
     253                        detalles = dir
     254
     255                    coordxy = getCoordenadas(ue)
     256
    245257                    try:
    246                         nombre = ue.nombreestablecimiento
     258                        estado = ue.parroquia.municipio.entidad.nombre
     259                        municipio = ue.parroquia.municipio.nombre
     260                        parroquia = ue.parroquia.nombre
    247261                    except AttributeError:
    248                         nombre = ue.nombre_comercial
    249                     dir += ue.direccion
    250 
    251                 if dir.__len__() > 11:
    252                     detalles = dir
    253 
    254                 coordxy = getCoordenadas(ue)
    255 
    256                 try:
    257                     estado = ue.parroquia.municipio.entidad.nombre
    258                     municipio = ue.parroquia.municipio.nombre
    259                     parroquia = ue.parroquia.nombre
    260                 except AttributeError:
    261                     estado = ''
    262                     municipio = ''
    263                     parroquia = ''
    264 
    265                 produce = ""
    266                 consume = ""
    267                 conn = [g for g in grafo.edges() if c in g]
    268 
    269                 # Verifica la producción e insumos de las Unidades Económicas
    270                 for cx in conn:
    271                     if cx[0] == c and cx[1].attr['label'][0] != "J" and cx[1].attr['label'].split("\\n")[1] != "":
    272                         produce += "<li>%s</li>" % cx[1].attr['label'].split("\\n")[1]
    273                     elif cx[1] == c and cx[0].attr['label'][0] != "J" and cx[0].attr['label'].split("\\n")[1] != "":
    274                         consume += "<li>%s</li>" % cx[0].attr['label'].split("\\n")[1]
    275 
    276                 if produce != "":
    277                     produce = "<ul style='list-style-type: circle;'>%s</ul>" % produce
    278                 if consume != "":
    279                     consume = "<ul style='list-style-type: circle;'>%s</ul>" % consume
    280 
    281                 if coordxy:
    282                     cadena.append({'lon': coordxy[0],
    283                                    'lat': coordxy[1],
    284                                    'icono': icono,
    285                                    'uerif': grafo.get_node(c).attr['label'][0:10],
    286                                    'uenombre': nombre,
    287                                    'uedetalles': detalles,
    288                                    'ueproduce': produce,
    289                                    'ueconsume': consume,
    290                                    'ueedo': estado,
    291                                    'uemun': municipio,
    292                                    'ueparr': parroquia,
    293                                    'nivel': nivel})
     262                        estado = ''
     263                        municipio = ''
     264                        parroquia = ''
     265
     266                    produce = ""
     267                    consume = ""
     268                    conn = [g for g in grafo.edges() if c in g]
     269
     270                    # Verifica la producción e insumos de las Unidades Económicas
     271                    for cx in conn:
     272                        if cx[0] == c and not cx[1].attr['label'][0] in ['J', 'G', 'V', 'E', 'P'] \
     273                                and cx[1].attr['label'].split("\\n")[1] != "":
     274                            produce += "<li>%s</li>" % cx[1].attr['label'].split("\\n")[1]
     275                        elif cx[1] == c and not cx[0].attr['label'][0] in ['J', 'G', 'V', 'E', 'P'] \
     276                                and cx[0].attr['label'].split("\\n")[1] != "":
     277                            consume += "<li>%s</li>" % cx[0].attr['label'].split("\\n")[1]
     278
     279                    if produce != "":
     280                        produce = "<ul style='list-style-type: circle;'>%s</ul>" % produce
     281                    if consume != "":
     282                        consume = "<ul style='list-style-type: circle;'>%s</ul>" % consume
     283
     284                    if coordxy:
     285                        cadena.append({'lon': coordxy[0],
     286                                       'lat': coordxy[1],
     287                                       'icono': icono,
     288                                       'uerif': grafo.get_node(c).attr['label'][0:10],
     289                                       'uenombre': nombre,
     290                                       'uedetalles': detalles,
     291                                       'ueproduce': produce,
     292                                       'ueconsume': consume,
     293                                       'ueedo': estado,
     294                                       'uemun': municipio,
     295                                       'ueparr': parroquia,
     296                                       'nivel': nivel})
    294297    except Exception, e:
    295         pass
     298        print e
    296299
    297300    return cadena
Note: See TracChangeset for help on using the changeset viewer.