86 lines
2.1 KiB
Python
86 lines
2.1 KiB
Python
"""
|
|
ExportsFactory export a city into several formats
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|
"""
|
|
|
|
from exports.formats.stl import Stl
|
|
from exports.formats.obj import Obj
|
|
from exports.formats.energy_ade import EnergyAde
|
|
from exports.formats.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
|
|
from exports.formats.idf import Idf
|
|
from pathlib import Path
|
|
|
|
|
|
class ExportsFactory:
|
|
"""
|
|
Exports factory class
|
|
"""
|
|
def __init__(self, export_type, city, path):
|
|
self._city = city
|
|
self._export_type = '_' + export_type.lower()
|
|
self._path = path
|
|
|
|
@property
|
|
def _citygml(self):
|
|
"""
|
|
Export to citygml_classes with application domain extensions
|
|
:return: None
|
|
"""
|
|
raise NotImplementedError
|
|
|
|
@property
|
|
def _energy_ade(self):
|
|
"""
|
|
Export to citygml_classes with application domain extensions
|
|
:return: None
|
|
"""
|
|
return EnergyAde(self._city, self._path)
|
|
|
|
@property
|
|
def _stl(self):
|
|
"""
|
|
Export the city geometry to stl
|
|
:return: None
|
|
"""
|
|
return Stl(self._city, self._path)
|
|
|
|
@property
|
|
def _obj(self):
|
|
"""
|
|
Export the city geometry to obj
|
|
:return: None
|
|
"""
|
|
return Obj(self._city, self._path)
|
|
|
|
@property
|
|
def _grounded_obj(self):
|
|
"""
|
|
Export the city geometry to obj
|
|
:return: None
|
|
"""
|
|
return Obj(self._city, self._path).to_ground_points()
|
|
|
|
@property
|
|
def _idf(self):
|
|
"""
|
|
Export the city to Energy+ idf format
|
|
:return:
|
|
"""
|
|
# todo: this need to be generalized
|
|
data_path = Path('test/data').resolve()
|
|
return Idf(self._city, self._path, (data_path / f'minimal.idf').resolve(), (data_path / f'energy+.idd').resolve(),
|
|
(data_path / f'montreal.epw').resolve())
|
|
|
|
@property
|
|
def _sra(self):
|
|
return SimplifiedRadiosityAlgorithm(self._city, (self._path / f'{self._city.name}_sra.xml'))
|
|
|
|
def export(self):
|
|
"""
|
|
Export the city model structure to the given export type
|
|
:return: None
|
|
"""
|
|
return getattr(self, self._export_type, lambda: None)
|
|
|