From 354923b37800d639d146e66f16a082f7fea7d665 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Tue, 25 Apr 2023 09:59:52 -0400 Subject: [PATCH 1/6] added dictionary to access montreal custom costs catalog --- .../data/hub_function_to_nrel_construction_function.py | 2 +- hub/helpers/dictionaries.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hub/helpers/data/hub_function_to_nrel_construction_function.py b/hub/helpers/data/hub_function_to_nrel_construction_function.py index 2c0a2906..0d9aedd8 100644 --- a/hub/helpers/data/hub_function_to_nrel_construction_function.py +++ b/hub/helpers/data/hub_function_to_nrel_construction_function.py @@ -67,7 +67,7 @@ class HubFunctionToNrelConstructionFunction: cte.MUSEUM: 'n/a', cte.PERFORMING_ARTS_THEATRE: 'n/a', cte.TRANSPORTATION: 'n/a', - cte.AUTOMOTIVE_FACILITY: 'n/aquebec_to_hub', + cte.AUTOMOTIVE_FACILITY: 'n/a', cte.PARKING_GARAGE: 'n/a', cte.RELIGIOUS: 'n/a', cte.NON_HEATED: 'n/a' diff --git a/hub/helpers/dictionaries.py b/hub/helpers/dictionaries.py index 1fc73fde..3b5a9970 100644 --- a/hub/helpers/dictionaries.py +++ b/hub/helpers/dictionaries.py @@ -14,6 +14,7 @@ from hub.helpers.data.hub_function_to_nrcan_construction_function import HubFunc from hub.helpers.data.hub_usage_to_comnet_usage import HubUsageToComnetUsage from hub.helpers.data.hub_usage_to_hft_usage import HubUsageToHftUsage from hub.helpers.data.hub_usage_to_nrcan_usage import HubUsageToNrcanUsage +from hub.helpers.data.hub_function_to_montreal_custom_costs_function import HubFunctionToMontrealCustomCostsFunction class Dictionaries: @@ -91,3 +92,11 @@ class Dictionaries: """ return AlkisFunctionToHubFunction().dictionary + @property + def hub_function_to_montreal_custom_costs_function(self) -> dict: + """ + Get hub function to Montreal custom costs function, transformation dictionary + :return: dict + """ + return HubFunctionToMontrealCustomCostsFunction().dictionary + From 745c1e6843505c60c771f6daae89590075dfa937 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Tue, 25 Apr 2023 10:00:07 -0400 Subject: [PATCH 2/6] added dictionary to access montreal custom costs catalog --- ...ction_to_montreal_custom_costs_function.py | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 hub/helpers/data/hub_function_to_montreal_custom_costs_function.py diff --git a/hub/helpers/data/hub_function_to_montreal_custom_costs_function.py b/hub/helpers/data/hub_function_to_montreal_custom_costs_function.py new file mode 100644 index 00000000..5e0d58f5 --- /dev/null +++ b/hub/helpers/data/hub_function_to_montreal_custom_costs_function.py @@ -0,0 +1,78 @@ +""" +Dictionaries module for hub function to Montreal custom costs function +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2022 Concordia CERC group +Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca +""" + +import hub.helpers.constants as cte + + +class HubFunctionToMontrealCustomCostsFunction: + + def __init__(self): + self._dictionary = { + cte.RESIDENTIAL: 'residential', + cte.SINGLE_FAMILY_HOUSE: 'residential', + cte.MULTI_FAMILY_HOUSE: 'residential', + cte.ROW_HOUSE: 'residential', + cte.MID_RISE_APARTMENT: 'residential', + cte.HIGH_RISE_APARTMENT: 'residential', + cte.OFFICE_AND_ADMINISTRATION: 'non-residential', + cte.SMALL_OFFICE: 'non-residential', + cte.MEDIUM_OFFICE: 'non-residential', + cte.LARGE_OFFICE: 'non-residential', + cte.COURTHOUSE: 'non-residential', + cte.FIRE_STATION: 'non-residential', + cte.PENITENTIARY: 'non-residential', + cte.POLICE_STATION: 'non-residential', + cte.POST_OFFICE: 'non-residential', + cte.LIBRARY: 'non-residential', + cte.EDUCATION: 'non-residential', + cte.PRIMARY_SCHOOL: 'non-residential', + cte.PRIMARY_SCHOOL_WITH_SHOWER: 'non-residential', + cte.SECONDARY_SCHOOL: 'non-residential', + cte.UNIVERSITY: 'non-residential', + cte.LABORATORY_AND_RESEARCH_CENTER: 'non-residential', + cte.STAND_ALONE_RETAIL: 'non-residential', + cte.HOSPITAL: 'non-residential', + cte.OUT_PATIENT_HEALTH_CARE: 'non-residential', + cte.HEALTH_CARE: 'non-residential', + cte.RETIREMENT_HOME_OR_ORPHANAGE: 'non-residential', + cte.COMMERCIAL: 'non-residential', + cte.STRIP_MALL: 'non-residential', + cte.SUPERMARKET: 'non-residential', + cte.RETAIL_SHOP_WITHOUT_REFRIGERATED_FOOD: 'non-residential', + cte.RETAIL_SHOP_WITH_REFRIGERATED_FOOD: 'non-residential', + cte.RESTAURANT: 'full service restaurant', + cte.QUICK_SERVICE_RESTAURANT: 'non-residential', + cte.FULL_SERVICE_RESTAURANT: 'non-residential', + cte.HOTEL: 'non-residential', + cte.HOTEL_MEDIUM_CLASS: 'non-residential', + cte.SMALL_HOTEL: 'non-residential', + cte.LARGE_HOTEL: 'non-residential', + cte.DORMITORY: 'non-residential', + cte.EVENT_LOCATION: 'non-residential', + cte.CONVENTION_CENTER: 'non-residential', + cte.HALL: 'non-residential', + cte.GREEN_HOUSE: 'non-residential', + cte.INDUSTRY: 'non-residential', + cte.WORKSHOP: 'non-residential', + cte.WAREHOUSE: 'non-residential', + cte.WAREHOUSE_REFRIGERATED: 'non-residential', + cte.SPORTS_LOCATION: 'non-residential', + cte.SPORTS_ARENA: 'non-residential', + cte.GYMNASIUM: 'non-residential', + cte.MOTION_PICTURE_THEATRE: 'non-residential', + cte.MUSEUM: 'non-residential', + cte.PERFORMING_ARTS_THEATRE: 'non-residential', + cte.TRANSPORTATION: 'non-residential', + cte.AUTOMOTIVE_FACILITY: 'non-residential', + cte.PARKING_GARAGE: 'non-residential', + cte.RELIGIOUS: 'non-residential', + cte.NON_HEATED: 'non-residential' + } + + @property + def dictionary(self) -> dict: + return self._dictionary From 4ab741ee120c9feb0c1112ba1aa8c6db689c5ab2 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Tue, 25 Apr 2023 10:23:37 -0400 Subject: [PATCH 3/6] changed hardcoded path to relative path in costs catalog --- hub/catalog_factories/cost/montreal_custom_catalog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hub/catalog_factories/cost/montreal_custom_catalog.py b/hub/catalog_factories/cost/montreal_custom_catalog.py index 5df24d9f..894695cf 100644 --- a/hub/catalog_factories/cost/montreal_custom_catalog.py +++ b/hub/catalog_factories/cost/montreal_custom_catalog.py @@ -20,7 +20,7 @@ from hub.catalog_factories.data_models.cost.cost_helper import CostHelper class MontrealCustomCatalog(Catalog): def __init__(self, path): - path = 'C:/Users/JGAVALDA/PycharmProjects/hub/hub/data/costs/montreal_costs.xml' + path = (path / 'montreal_costs.xml') with open(path) as xml: self._archetypes = xmltodict.parse(xml.read(), force_list='archetype') From 3d6699f71f3bbd155718ceb517afc8fd45550d41 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Tue, 25 Apr 2023 10:27:27 -0400 Subject: [PATCH 4/6] changed hardcoded path to relative path in costs catalog factory --- hub/catalog_factories/costs_catalog_factory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hub/catalog_factories/costs_catalog_factory.py b/hub/catalog_factories/costs_catalog_factory.py index d628baee..51bafe17 100644 --- a/hub/catalog_factories/costs_catalog_factory.py +++ b/hub/catalog_factories/costs_catalog_factory.py @@ -19,7 +19,7 @@ class CostCatalogFactory: """ def __init__(self, file_type, base_path=None): if base_path is None: - base_path = 'C:/Users/JGAVALDA/PycharmProjects/hub/hub/data/costs' + base_path = Path(Path(__file__).parent.parent / 'data/costs') self._catalog_type = '_' + file_type.lower() self._path = base_path From 150614441e464edbb9230300cdbfa48beef08eaf Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Tue, 25 Apr 2023 10:45:56 -0400 Subject: [PATCH 5/6] erased two prints, fixed a bug in geometry helper and modified name in costs archetype --- hub/catalog_factories/data_models/cost/archetype.py | 2 +- hub/helpers/geometry_helper.py | 4 ++-- hub/imports/geometry/geojson.py | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/hub/catalog_factories/data_models/cost/archetype.py b/hub/catalog_factories/data_models/cost/archetype.py index cf24c6ee..97cabe1a 100644 --- a/hub/catalog_factories/data_models/cost/archetype.py +++ b/hub/catalog_factories/data_models/cost/archetype.py @@ -38,7 +38,7 @@ class Archetype: Get name :return: string """ - return f'{self._country}_{self._municipality}_{self._function}_{self._lod}' + return f'{self._country}_{self._municipality}_{self._function}_lod{self._lod}' @property def lod(self): diff --git a/hub/helpers/geometry_helper.py b/hub/helpers/geometry_helper.py index b4e20351..e9b9a6d9 100644 --- a/hub/helpers/geometry_helper.py +++ b/hub/helpers/geometry_helper.py @@ -100,9 +100,9 @@ class GeometryHelper: j = 0 next_coordinate = ground.perimeter_polygon.coordinates[j] distance = GeometryHelper.distance_between_points(coordinate, next_coordinate) - if distance == 0: - continue steps = int(distance * factor * 2) + if steps == 0: + continue delta_x = (next_coordinate[0] - coordinate[0]) / steps delta_y = (next_coordinate[1] - coordinate[1]) / steps diff --git a/hub/imports/geometry/geojson.py b/hub/imports/geometry/geojson.py index 4fd9d340..92086b22 100644 --- a/hub/imports/geometry/geojson.py +++ b/hub/imports/geometry/geojson.py @@ -173,8 +173,6 @@ class Geojson: GeometryHelper.distance_between_points(neighbour_line[0], neighbour_line[1]) - GeometryHelper.distance_between_points(line[1], neighbour_line[0]) - GeometryHelper.distance_between_points(line[0], neighbour_line[1])) / 2 - print(line_shared) - print() percentage_ground = line_shared / GeometryHelper.distance_between_points(line[0], line[1]) percentage_height = neighbour_height / building.max_height if percentage_height > 1: From 2dfe8254d1ea44bc3da9a6cdea4891486f56d5c9 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Tue, 25 Apr 2023 11:48:24 -0400 Subject: [PATCH 6/6] added new functions to access chapter and item by name in costs catalog --- hub/catalog_factories/data_models/cost/capital_cost.py | 10 ++++++++++ hub/catalog_factories/data_models/cost/chapter.py | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/hub/catalog_factories/data_models/cost/capital_cost.py b/hub/catalog_factories/data_models/cost/capital_cost.py index 828b5cfc..94981e42 100644 --- a/hub/catalog_factories/data_models/cost/capital_cost.py +++ b/hub/catalog_factories/data_models/cost/capital_cost.py @@ -38,3 +38,13 @@ class CapitalCost: :return: float """ return self._overhead_and_profit + + def chapter(self, name) -> Chapter: + """ + Get specific chapter by name + :return: Chapter + """ + for chapter in self.general_chapters: + if chapter.chapter_type == name: + return chapter + raise KeyError(f'Chapter name {name} not found') diff --git a/hub/catalog_factories/data_models/cost/chapter.py b/hub/catalog_factories/data_models/cost/chapter.py index bf393cbb..2cd7b4e6 100644 --- a/hub/catalog_factories/data_models/cost/chapter.py +++ b/hub/catalog_factories/data_models/cost/chapter.py @@ -30,3 +30,13 @@ class Chapter: :return: [str] """ return self._items + + def item(self, name) -> ItemDescription: + """ + Get specific item by name + :return: ItemDescription + """ + for item in self.items: + if item.type == name: + return item + raise KeyError(f'Item name {name} not found')