forked from s_ranjbar/city_retrofit
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
from city_model_structure.city_object import CityObject
|
|
from typing import List, Union
|
|
|
|
|
|
class City:
|
|
def __init__(self, lower_corner, upper_corner, srs_name, city_objects=None):
|
|
self._city_objects = None
|
|
self._name = None
|
|
self._lower_corner = lower_corner
|
|
self._upper_corner = upper_corner
|
|
self._city_objects = city_objects
|
|
self._srs_name = srs_name
|
|
|
|
@property
|
|
def city_objects(self) -> Union[List[CityObject], None]:
|
|
return self._city_objects
|
|
|
|
@property
|
|
def lower_corner(self):
|
|
return self._lower_corner
|
|
|
|
@property
|
|
def upper_corner(self):
|
|
return self._upper_corner
|
|
|
|
def city_object(self, name) -> Union[CityObject, None]:
|
|
for c in self.city_objects:
|
|
if c.name == name:
|
|
return c
|
|
return None
|
|
|
|
def add_city_object(self, new_city_object):
|
|
if self.city_objects is None:
|
|
self._city_objects = []
|
|
for city_object in self.city_objects:
|
|
# ToDo: Check for shared walls.
|
|
for surface in city_object.surfaces:
|
|
for surface2 in new_city_object.surfaces:
|
|
surface.shared(surface2)
|
|
self._city_objects.append(new_city_object)
|
|
|
|
@property
|
|
def srs_name(self):
|
|
return self._srs_name
|
|
|
|
@property
|
|
def name(self):
|
|
return self._name
|
|
|
|
@name.setter
|
|
def name(self, value):
|
|
self._name = value
|