Skip to content

Instantly share code, notes, and snippets.

@mvexel
Last active August 29, 2015 14:14
Show Gist options
  • Save mvexel/33d752f2f10212f4855e to your computer and use it in GitHub Desktop.
Save mvexel/33d752f2f10212f4855e to your computer and use it in GitHub Desktop.
mx-inegi.py
# -*- coding: latin-1 -*-
'''
A translator for Mexican INEGI data
VECTORIAL DE LOCALIDADES AMANZANADAS Y NÚMEROS EXTERIORES
'''
def parseName(roadName, roadType):
import string
return string.capwords(roadType + ' ' + roadName)
def filterTags(attrs):
if not attrs:
return
tags = {}
if 'TIPOVIAL' in attrs:
if 'NOMVIAL' in attrs:
tags['name'] = parseName(attrs['NOMVIAL'], attrs['TIPOVIAL'])
native_road_class = attrs['TIPOVIAL'].strip()
if native_road_class == 'CARRETERA':
tags['highway'] = 'motorway'
elif native_road_class == 'AUTOPISTA':
tags['highway'] = 'motorway'
elif native_road_class == u'CONTINUACIÓN':
tags['highway'] = 'trunk'
elif native_road_class == u'PERIFÉRICO':
tags['highway'] = 'trunk'
elif native_road_class == 'VIADUCTO':
tags['highway'] = 'trunk'
elif native_road_class == 'CALZADA':
tags['highway'] = 'primary'
elif native_road_class == 'BOULEVARD':
tags['highway'] = 'primary'
elif native_road_class == u'AMPLIACIÓN':
tags['highway'] = 'primary'
elif native_road_class == 'CIRCUITO':
tags['highway'] = 'primary'
elif native_road_class == 'EJE VIAL':
tags['highway'] = 'primary'
elif native_road_class == u'PROLONGACIÓN':
tags['highway'] = 'primary'
elif native_road_class == 'CORREDOR':
tags['highway'] = 'tertiary'
elif native_road_class == 'RETORNO':
tags['highway'] = 'tertiary'
elif native_road_class == 'DIAGONAL':
tags['highway'] = 'secondary'
elif native_road_class == 'CERRADA':
tags['highway'] = 'residential'
elif native_road_class == 'PRIVADA':
tags['highway'] = 'residential'
elif native_road_class == 'CALLE':
tags['highway'] = 'residential'
elif native_road_class == 'AVENIDA':
tags['highway'] = 'residential'
elif native_road_class == 'ANDADOR':
tags['highway'] = 'pedestrian'
elif native_road_class == 'PASAJE':
tags['highway'] = 'pedestrian'
elif native_road_class == 'PEATONAL':
tags['highway'] = 'pedestrian'
elif native_road_class == u'CALLEJÓN':
tags['highway'] = 'service'
tags['service'] = 'alley'
elif native_road_class == 'NINGUNO':
tags['highway'] = 'unclassified'
elif native_road_class == 'OTRO':
tags['highway'] = 'unclassified'
elif native_road_class == 'ENLACE':
tags['highway'] = 'motorway_link'
elif native_road_class == 'GLORIETA':
tags['highway'] = 'motorway_link'
tags['junction'] = 'roundabout'
elif native_road_class == 'BRECHA':
tags['highway'] = 'unclassified'
elif native_road_class == 'PLAZA':
tags['highway'] = 'unclassified'
elif native_road_class == 'VEREDA':
tags['highway'] = 'pedestrian'
elif native_road_class == 'TERRACERIA':
tags['highway'] = 'track'
elif native_road_class == 'RAMPA DE FRENADO':
tags['highway'] = 'escape'
else:
tags['highway'] = 'road'
tags['inegi:roadtype'] = native_road_class
tags['source'] = 'INEGI'
print tags
return tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment