Included energy systems attribute

This commit is contained in:
Peter Yefi 2021-10-21 13:49:26 +00:00
parent df3f33b45a
commit 567fde0012

View File

@ -2,6 +2,7 @@
City module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
Contributor Peter Yefi peteryefi@gmail.com
"""
from __future__ import annotations
import sys
@ -20,6 +21,7 @@ from city_model_structure.parts_consisting_building import PartsConsistingBuildi
from city_model_structure.subway_entrance import SubwayEntrance
from helpers.geometry_helper import GeometryHelper
from helpers.location import Location
from city_model_structure.energy_system import EnergySystem
class City:
@ -47,6 +49,7 @@ class City:
self._parts_consisting_buildings = None
self._city_objects_clusters = None
self._city_objects = None
self._energy_systems = None
def _get_location(self) -> Location:
if self._location is None:
@ -129,6 +132,9 @@ class City:
if self.subway_entrances is not None:
for subway_entrance in self.subway_entrances:
self._city_objects.append(subway_entrance)
if self.energy_systems is not None:
for energy_system in self.energy_systems:
self._city_objects.append(energy_system)
return self._city_objects
@property
@ -188,6 +194,10 @@ class City:
if self._subway_entrances is None:
self._subway_entrances = []
self._subway_entrances.append(new_city_object)
elif new_city_object.type == 'energy_system':
if self._energy_systems is None:
self._energy_systems = []
self._energy_systems.append(new_city_object)
else:
raise NotImplementedError(new_city_object.type)
@ -252,12 +262,12 @@ class City:
selected_region_upper_corner = [center[0] + radius, center[1] + radius, center[2] + radius]
selected_region_city = City(selected_region_lower_corner, selected_region_upper_corner, srs_name=self.srs_name)
selected_region_city.climate_file = self.climate_file
# selected_region_city.climate_reference_city = self.climate_reference_city
# selected_region_city.climate_reference_city = self.climate_reference_city
for city_object in self.city_objects:
location = city_object.centroid
if location is not None:
distance = math.sqrt(math.pow(location[0]-center[0], 2) + math.pow(location[1]-center[1], 2)
+ math.pow(location[2]-center[2], 2))
distance = math.sqrt(math.pow(location[0] - center[0], 2) + math.pow(location[1] - center[1], 2)
+ math.pow(location[2] - center[2], 2))
if distance < radius:
selected_region_city.add_city_object(city_object)
return selected_region_city
@ -329,6 +339,14 @@ class City:
"""
return self._parts_consisting_buildings
@property
def energy_systems(self) -> Union[List[EnergySystem], None]:
"""
Get energy systems belonging to the city
:return: None or [EnergySystem]
"""
return self._energy_systems
@property
def city_objects_clusters(self) -> Union[List[CityObjectsCluster], None]:
"""