test geometry update
This commit is contained in:
parent
a9b3859dce
commit
dc1515bb0d
21
city_model_structure/subway_entrance.py
Normal file
21
city_model_structure/subway_entrance.py
Normal file
|
@ -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
|
|
@ -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]:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user