94c593b651
re-structured weather.py file accordingly (now in weather_factory.helpers
29 lines
939 B
Python
29 lines
939 B
Python
"""
|
|
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
|
|
from city_model_structure.subway_entrance import SubwayEntrance
|
|
|
|
|
|
class OsmSubway:
|
|
def __init__(self, path):
|
|
self._subway_entrances = []
|
|
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':
|
|
subway_entrance = SubwayEntrance(node['@id'], node['@lat'], node['@lon'])
|
|
self._subway_entrances.append(subway_entrance)
|
|
|
|
@property
|
|
def subway_entrances(self):
|
|
return self._subway_entrances
|