system_assignation/imports/geometry_feeders/osm_subway.py

29 lines
939 B
Python
Raw Normal View History

2020-06-30 16:51:49 -04:00
"""
OsmSubway module parses osm files and import the metro location into the city model structure
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
import xmltodict
2020-06-30 18:06:27 -04:00
from city_model_structure.subway_entrance import SubwayEntrance
2020-06-30 16:51:49 -04:00
class OsmSubway:
def __init__(self, path):
2020-06-30 18:06:27 -04:00
self._subway_entrances = []
2020-06-30 16:51:49 -04:00
with open(path) as osm:
self._osm = xmltodict.parse(osm.read(), force_list='tag')
for node in self._osm['osm']['node']:
if 'tag' not in node:
continue
for tag in node['tag']:
if '@v' not in tag:
continue
if tag['@v'] == 'subway_entrance':
2020-06-30 18:06:27 -04:00
subway_entrance = SubwayEntrance(node['@id'], node['@lat'], node['@lon'])
self._subway_entrances.append(subway_entrance)
@property
def subway_entrances(self):
return self._subway_entrances