Merge remote-tracking branch 'origin/geojson' into geojson

This commit is contained in:
Guille Gutierrez 2023-04-27 10:59:08 -04:00
commit 7c0e03d0e0
10 changed files with 113 additions and 8 deletions

View File

@ -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')

View File

@ -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

View File

@ -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):

View File

@ -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')

View File

@ -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')

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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: