hub/imports/geometry_factory.py

40 lines
970 B
Python
Raw Normal View History

2020-06-09 14:07:47 -04:00
"""
GeometryFactory retrieve the specific geometric module to load the given format
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
from city_model_structure.city import City
from imports.geometry.citygml import CityGml
from imports.geometry.obj import Obj
2021-08-27 12:51:30 -04:00
from imports.geometry.osm_subway import OsmSubway
class GeometryFactory:
2020-06-15 11:38:18 -04:00
"""
GeometryFactory class
"""
def __init__(self, file_type, path):
self._file_type = '_' + file_type.lower()
self._path = path
@property
def _citygml(self):
return CityGml(self._path).city
2021-03-16 16:58:52 -04:00
@property
def _obj(self):
2021-08-27 12:51:30 -04:00
return Obj(self._path).city
2021-03-16 16:58:52 -04:00
@property
2021-08-27 12:51:30 -04:00
def _osm_subway(self):
return OsmSubway(self._path).city
@property
def city(self) -> City:
"""
2020-06-15 11:38:18 -04:00
Load the city model structure from a geometry source
:return: City
"""
return getattr(self, self._file_type, lambda: None)