system_assignation/imports/geometry_factory.py

82 lines
2.0 KiB
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
2020-06-30 16:14:39 -04:00
from city_model_structure.city_object import CityObject
2021-03-16 20:14:40 -04:00
from imports.geometry_feeders.citygml import CityGml
from imports.geometry_feeders.osm_subway import OsmSubway
2021-03-16 16:58:52 -04:00
from imports.geometry_feeders.obj import Obj
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
@property
def _stl(self):
raise Exception('Not implemented')
2021-03-16 16:58:52 -04:00
@property
def _obj(self):
return Obj(self._path).scene
@property
def _geojson(self):
raise Exception('Not implemented')
@property
def _bim(self):
raise Exception('Not implemented')
@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)
2020-06-30 16:14:39 -04:00
2021-03-16 16:58:52 -04:00
@property
def scene(self):
"""
Load the city model structure from a geometry source
:return: Trimesh scene
2021-03-16 16:58:52 -04:00
"""
return getattr(self, self._file_type, lambda: None)
@property
def _scene_debug(self):
"""
just for debug. More information is provided without the lambda parameter
"""
return getattr(self, self._file_type)
@property
def _city_debug(self):
"""
just for debug. More information is provided without the lambda parameter
"""
2021-04-07 14:20:13 -04:00
return Obj(self._path).city
2020-06-30 16:14:39 -04:00
@property
def _osm_subway(self):
2020-06-30 18:06:27 -04:00
return OsmSubway(self._path).subway_entrances
2020-06-30 16:14:39 -04:00
@property
def features(self) -> [CityObject]:
"""
Load the city model structure from a geometry source
:return: [CityObject]
"""
return getattr(self, self._file_type, lambda: None)