2021-03-16 12:33:22 -04:00
|
|
|
"""
|
|
|
|
ExportsFactory export a city into several formats
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
2021-03-16 12:33:22 -04:00
|
|
|
"""
|
|
|
|
|
2021-08-25 07:23:02 -04:00
|
|
|
from pathlib import Path
|
2021-08-26 13:27:43 -04:00
|
|
|
from exports.formats.obj import Obj
|
|
|
|
from exports.formats.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
|
|
|
|
from exports.formats.stl import Stl
|
2021-03-16 12:33:22 -04:00
|
|
|
|
2021-03-16 16:58:52 -04:00
|
|
|
|
2021-03-16 12:33:22 -04:00
|
|
|
class ExportsFactory:
|
|
|
|
"""
|
|
|
|
Exports factory class
|
|
|
|
"""
|
2022-11-07 15:04:51 -05:00
|
|
|
def __init__(self, export_type, city, path, target_buildings=None, adjacent_buildings=None):
|
2021-03-16 12:33:22 -04:00
|
|
|
self._city = city
|
|
|
|
self._export_type = '_' + export_type.lower()
|
2022-04-06 16:06:55 -04:00
|
|
|
if isinstance(path, str):
|
|
|
|
path = Path(path)
|
2021-03-16 12:33:22 -04:00
|
|
|
self._path = path
|
2021-09-02 12:30:37 -04:00
|
|
|
self._target_buildings = target_buildings
|
2022-11-07 15:04:51 -05:00
|
|
|
self._adjacent_buildings = adjacent_buildings
|
2021-03-16 12:33:22 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def _citygml(self):
|
|
|
|
"""
|
2021-09-22 07:25:53 -04:00
|
|
|
Export to citygml
|
2021-03-16 12:33:22 -04:00
|
|
|
:return: None
|
|
|
|
"""
|
2021-05-27 17:20:06 -04:00
|
|
|
raise NotImplementedError
|
2021-03-16 12:33:22 -04:00
|
|
|
|
2022-02-16 15:08:05 -05:00
|
|
|
@property
|
|
|
|
def _collada(self):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
2021-03-16 12:33:22 -04:00
|
|
|
@property
|
|
|
|
def _stl(self):
|
|
|
|
"""
|
|
|
|
Export the city geometry to stl
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
return Stl(self._city, self._path)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def _obj(self):
|
2021-04-13 14:12:45 -04:00
|
|
|
"""
|
|
|
|
Export the city geometry to obj
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
return Obj(self._city, self._path)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def _grounded_obj(self):
|
2021-03-16 12:33:22 -04:00
|
|
|
"""
|
2021-09-22 07:25:53 -04:00
|
|
|
Export the city geometry to obj with grounded coordinates
|
2021-03-16 12:33:22 -04:00
|
|
|
:return: None
|
|
|
|
"""
|
2021-03-16 16:58:52 -04:00
|
|
|
return Obj(self._city, self._path).to_ground_points()
|
2021-03-16 12:33:22 -04:00
|
|
|
|
2021-04-13 14:12:45 -04:00
|
|
|
@property
|
|
|
|
def _sra(self):
|
2021-09-02 12:30:37 -04:00
|
|
|
"""
|
|
|
|
Export the city to Simplified Radiosity Algorithm xml format
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
return SimplifiedRadiosityAlgorithm(self._city, (self._path / f'{self._city.name}_sra.xml'),
|
|
|
|
target_buildings=self._target_buildings)
|
2021-04-13 14:12:45 -04:00
|
|
|
|
2021-03-16 12:33:22 -04:00
|
|
|
def export(self):
|
|
|
|
"""
|
2021-09-22 07:25:53 -04:00
|
|
|
Export the city given to the class using the given export type handler
|
2021-04-07 11:52:39 -04:00
|
|
|
:return: None
|
2021-03-16 12:33:22 -04:00
|
|
|
"""
|
|
|
|
return getattr(self, self._export_type, lambda: None)
|
2022-04-06 16:06:55 -04:00
|
|
|
|
|
|
|
def export_debug(self):
|
|
|
|
"""
|
|
|
|
Export the city given to the class using the given export type handler
|
|
|
|
:return: None
|
|
|
|
"""
|
2022-11-25 12:40:13 -05:00
|
|
|
return Obj(self._city, self._path)
|