diff --git a/city_model_structure/subway_entrance.py b/city_model_structure/subway_entrance.py new file mode 100644 index 00000000..9235b0bc --- /dev/null +++ b/city_model_structure/subway_entrance.py @@ -0,0 +1,21 @@ +from city_model_structure.city_object import CityObject + + +class SubwayEntrance(CityObject): + def __init__(self, name, latitude, longitude): + super().__init__(0, [], name) + self._name = name + self._latitude = latitude + self._longitude = longitude + + @property + def latitude(self): + return self._latitude + + @property + def longitude(self): + return self._longitude + + @property + def name(self): + return self._name diff --git a/geometry/geometry_factory.py b/geometry/geometry_factory.py index d672e501..d1aa1476 100644 --- a/geometry/geometry_factory.py +++ b/geometry/geometry_factory.py @@ -39,7 +39,7 @@ class GeometryFactory: @property def _osm_subway(self): - return OsmSubway(self._path) + return OsmSubway(self._path).subway_entrances @property def features(self) -> [CityObject]: diff --git a/geometry/geometry_feeders/osm_subway.py b/geometry/geometry_feeders/osm_subway.py index 05cf6622..937493ae 100644 --- a/geometry/geometry_feeders/osm_subway.py +++ b/geometry/geometry_feeders/osm_subway.py @@ -5,10 +5,12 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc """ 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']: @@ -18,5 +20,9 @@ class OsmSubway: if '@v' not in tag: continue if tag['@v'] == 'subway_entrance': - print(tag['@v']) - print(node) + subway_entrance = SubwayEntrance(node['@id'], node['@lat'], node['@lon']) + self._subway_entrances.append(subway_entrance) + + @property + def subway_entrances(self): + return self._subway_entrances diff --git a/tests/test_geometry_factory.py b/tests/test_geometry_factory.py index 17253240..bcac1604 100644 --- a/tests/test_geometry_factory.py +++ b/tests/test_geometry_factory.py @@ -36,8 +36,9 @@ class TestGeometryFactory(TestCase): """ city = self._get_citygml() file_path = (self._example_path / 'subway.osm').resolve() - self._features = GeometryFactory('osm_subway', file_path).features - self.assertIsNotNone(city, 'city is none') + subway_entrances = self._features = GeometryFactory('osm_subway', file_path).features + self.assertIsNotNone(subway_entrances, 'subway entrances is none') + self.assertEquals(len(subway_entrances), 20, 'Wrong number of subway entrances') def test_citygml_city(self): """