forked from s_ranjbar/city_retrofit
Added unique id to city object
This commit is contained in:
parent
4f4f9fd6ec
commit
4e0fd65a5a
|
@ -14,7 +14,7 @@ import pyproj
|
|||
from typing import List, Union
|
||||
from pyproj import Transformer
|
||||
from pathlib import Path
|
||||
|
||||
import uuid
|
||||
from city_model_structure.building import Building
|
||||
from city_model_structure.city_object import CityObject
|
||||
from city_model_structure.city_objects_cluster import CityObjectsCluster
|
||||
|
@ -29,12 +29,14 @@ from helpers.location import Location
|
|||
from city_model_structure.energy_system import EnergySystem
|
||||
from city_model_structure.lca_material import LcaMaterial
|
||||
|
||||
|
||||
class City:
|
||||
"""
|
||||
City class
|
||||
"""
|
||||
|
||||
def __init__(self, lower_corner, upper_corner, srs_name):
|
||||
self.uid = str(uuid.uuid4())
|
||||
self._name = None
|
||||
self._lower_corner = lower_corner
|
||||
self._upper_corner = upper_corner
|
||||
|
@ -93,7 +95,7 @@ class City:
|
|||
@property
|
||||
def country_code(self):
|
||||
"""
|
||||
Get city country code
|
||||
Get models country code
|
||||
:return: str
|
||||
"""
|
||||
return self._get_location().country
|
||||
|
@ -287,12 +289,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
|
||||
|
|
Loading…
Reference in New Issue
Block a user