forked from s_ranjbar/city_retrofit
performance improvements in city import
This commit is contained in:
parent
b722125c3e
commit
2781696f95
|
@ -60,6 +60,7 @@ class City:
|
|||
self._stations = []
|
||||
self._lca_materials = None
|
||||
self._level_of_detail = LevelOfDetail()
|
||||
self._city_objects_dictionary = {}
|
||||
|
||||
@property
|
||||
def fuels(self) -> [Fuel]:
|
||||
|
@ -198,9 +199,8 @@ class City:
|
|||
:param name:str
|
||||
:return: None or CityObject
|
||||
"""
|
||||
for city_object in self.buildings:
|
||||
if str(city_object.name) == str(name):
|
||||
return city_object
|
||||
if name in self._city_objects_dictionary:
|
||||
return self.buildings[self._city_objects_dictionary[name]]
|
||||
return None
|
||||
|
||||
def add_city_object(self, new_city_object):
|
||||
|
@ -213,6 +213,7 @@ class City:
|
|||
if self._buildings is None:
|
||||
self._buildings = []
|
||||
self._buildings.append(new_city_object)
|
||||
self._city_objects_dictionary[new_city_object.name] = len(self._buildings) - 1
|
||||
elif new_city_object.type == 'energy_system':
|
||||
if self._energy_systems is None:
|
||||
self._energy_systems = []
|
||||
|
|
|
@ -6,8 +6,10 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|||
Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||
"""
|
||||
import math
|
||||
|
||||
import numpy as np
|
||||
import requests
|
||||
from PIL import Image
|
||||
from trimesh import Trimesh
|
||||
from trimesh import intersections
|
||||
|
||||
|
@ -15,8 +17,6 @@ from hub.city_model_structure.attributes.polygon import Polygon
|
|||
from hub.city_model_structure.attributes.polyhedron import Polyhedron
|
||||
from hub.helpers.location import Location
|
||||
|
||||
from PIL import Image
|
||||
|
||||
|
||||
class MapPoint:
|
||||
def __init__(self, x, y):
|
||||
|
@ -87,6 +87,7 @@ class GeometryHelper:
|
|||
for ground in building.grounds:
|
||||
length = len(ground.perimeter_polygon.coordinates) - 1
|
||||
for i, coordinate in enumerate(ground.perimeter_polygon.coordinates):
|
||||
|
||||
j = i + 1
|
||||
if i == length:
|
||||
j = 0
|
||||
|
@ -166,6 +167,7 @@ class GeometryHelper:
|
|||
elif building not in neighbour.neighbours:
|
||||
neighbour.neighbours.append(building)
|
||||
line += 1
|
||||
|
||||
if plot:
|
||||
img.show()
|
||||
return lines_information
|
||||
|
|
|
@ -237,8 +237,7 @@ class Geojson:
|
|||
self._city.level_of_detail.geometry = lod
|
||||
if lod == 1:
|
||||
start = datetime.datetime.now()
|
||||
lines_information = GeometryHelper.city_mapping(self._city, plot=True)
|
||||
print(lines_information)
|
||||
lines_information = GeometryHelper.city_mapping(self._city, plot=False)
|
||||
print(f'mapping: {datetime.datetime.now() - start}')
|
||||
start = datetime.datetime.now()
|
||||
self._store_shared_percentage_to_walls(self._city, lines_information)
|
||||
|
|
|
@ -105,4 +105,3 @@ class GeometryHelper:
|
|||
cosine = -1
|
||||
alpha = math.acos(cosine)
|
||||
return alpha
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user