From 5502261e16f1358bb6485f5a0a0175987ba98025 Mon Sep 17 00:00:00 2001 From: Pilar Date: Fri, 26 Jun 2020 18:10:56 -0700 Subject: [PATCH] moved data folder to libs and changed: def __init__(self, handler, city, base_path=Path(Path.cwd().parent / 'libs/data/physics')): in physics_factory.py plus the paths in us_base_physics_parameters.py Something similar should be done for usage_factory.py --- .idea/libs.iml | 6 ++++-- city_model_structure/city.py | 1 - helpers/geometry_helper.py | 4 ++-- physics/physics_factory.py | 5 +++-- .../physics_feeders/us_base_physics_parameters.py | 12 ++++++------ usage/usage_factory.py | 2 +- usage/usage_feeders/us_base_usage_parameters.py | 1 + 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.idea/libs.iml b/.idea/libs.iml index 43ad86bb..1d71bb07 100644 --- a/.idea/libs.iml +++ b/.idea/libs.iml @@ -1,8 +1,10 @@ - - + + + + \ No newline at end of file diff --git a/city_model_structure/city.py b/city_model_structure/city.py index 16691428..654428e5 100644 --- a/city_model_structure/city.py +++ b/city_model_structure/city.py @@ -42,7 +42,6 @@ class City: transformer = Transformer.from_crs(input_reference, gps) coordinates = transformer.transform(self.lower_corner[0], self.lower_corner[1]) self._location = GeometryHelper.get_location(coordinates[0], coordinates[1]) - # rg.search(coordinates) return self._location @property diff --git a/helpers/geometry_helper.py b/helpers/geometry_helper.py index 2716494a..513baedf 100644 --- a/helpers/geometry_helper.py +++ b/helpers/geometry_helper.py @@ -8,7 +8,6 @@ import math import numpy as np import open3d as o3d import requests -import json from trimesh import Trimesh from trimesh import intersections from helpers.configuration_helper import ConfigurationHelper @@ -21,7 +20,8 @@ class GeometryHelper: def __init__(self, delta=0.5): self._delta = delta - def adjacent_locations(self, location1, location2): + @staticmethod + def adjacent_locations(location1, location2): """ Determine when two buildings may be adjacent or not based in the dis :param location1: diff --git a/physics/physics_factory.py b/physics/physics_factory.py index 7c2e80a9..eb311fc2 100644 --- a/physics/physics_factory.py +++ b/physics/physics_factory.py @@ -5,19 +5,20 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc """ from physics.physics_feeders.us_new_york_city_physics_parameters import UsNewYorkCityPhysicsParameters from physics.physics_feeders.us_physics_parameters import UsPhysicsParameters +from pathlib import Path class PhysicsFactory: """ PhysicsFactor class """ - def __init__(self, handler, city, base_path='data/physics'): + def __init__(self, handler, city, base_path=Path(Path.cwd().parent / 'libs/data/physics')): self._handler = '_' + handler.lower().replace(' ', '_') self._city = city self._base_path = base_path self.factory() - def _us_new_york_city(self): + def _us_new_york(self): UsNewYorkCityPhysicsParameters(self._city, self._base_path) def _us(self): diff --git a/physics/physics_feeders/us_base_physics_parameters.py b/physics/physics_feeders/us_base_physics_parameters.py index 63d6584e..f6e9ae19 100644 --- a/physics/physics_feeders/us_base_physics_parameters.py +++ b/physics/physics_feeders/us_base_physics_parameters.py @@ -4,8 +4,6 @@ UsPhysicsParameters as base class SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ -from pathlib import Path - import xmltodict from city_model_structure.layer import Layer @@ -21,12 +19,14 @@ class UsBasePhysicsParameters: self._climate_zone = climate_zone self._buildings = buildings # load US Library - path = str(Path.cwd() / base_path / 'us_constructions.xml') + path = str(base_path / 'us_constructions.xml') + print('physics construction:', path) with open(path) as xml: self._library = xmltodict.parse(xml.read(), force_list='layer') # load US Archetypes - path = str(Path.cwd() / base_path / 'us_archetypes.xml') + path = str(base_path / 'us_archetypes.xml') + print('physics archetypes:', path) with open(path) as xml: self._archetypes = xmltodict.parse(xml.read(), force_list='layer') for building in self._buildings: @@ -40,8 +40,8 @@ class UsBasePhysicsParameters: # ToDo: remove this in the future # ToDo: Raise WrongArchetype if not all the surface types are defined for the given city_object if archetype is None: - print('Building ', city_object.name, 'has unknown archetype') - print('type: ', building_type, UsToLibraryTypes.yoc_to_standard(city_object.year_of_construction), + print('Building ', building.name, 'has unknown archetype') + print('type: ', building_type, UsToLibraryTypes.yoc_to_standard(building.year_of_construction), self._climate_zone) continue diff --git a/usage/usage_factory.py b/usage/usage_factory.py index ae84f8e9..870b98af 100644 --- a/usage/usage_factory.py +++ b/usage/usage_factory.py @@ -16,7 +16,7 @@ class UsageFactory: self._city = city self.factory() - def _us_new_york_city(self): + def _us_new_york(self): UsNewYorkCityUsageParameters(self._city) def _ca(self): diff --git a/usage/usage_feeders/us_base_usage_parameters.py b/usage/usage_feeders/us_base_usage_parameters.py index f0c55f93..f214bfd8 100644 --- a/usage/usage_feeders/us_base_usage_parameters.py +++ b/usage/usage_feeders/us_base_usage_parameters.py @@ -20,6 +20,7 @@ class UsBaseUsageParameters: # todo: control not archetype found # ToDo: this is using the german library as a temporary approach, need to use/define a library for US path = str(Path.cwd() / 'data/usage/de_library.xml') + print('usage:', path) with open(path) as xml: self._library = xmltodict.parse(xml.read(), force_list='zoneUsageVariant') for city_object in self._city.buildings: