Small clean up
This commit is contained in:
parent
82be9ee660
commit
bf6a5711ce
@ -8,9 +8,9 @@ import json
|
||||
from flask import Response, request, g
|
||||
from flask_restful import Resource
|
||||
from hub_api.helpers.auth import role_required
|
||||
from persistence.models import UserRoles
|
||||
from hub_logger import logger
|
||||
from imports.geometry_factory import GeometryFactory
|
||||
from hub.persistence.models import UserRoles
|
||||
from hub.hub_logger import logger
|
||||
from hub.imports.geometry_factory import GeometryFactory
|
||||
from pathlib import Path
|
||||
import os
|
||||
from hub_api.config import Config
|
||||
|
@ -3,8 +3,8 @@ Config
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2023 Project Peter Yefi peteryefi@gmail.com
|
||||
"""
|
||||
from exports.db_factory import DBFactory as CityExportFactory
|
||||
from imports.db_factory import DBFactory
|
||||
from hub.exports.db_factory import DBFactory as CityExportFactory
|
||||
from hub.imports.db_factory import DBFactory
|
||||
import os
|
||||
import pickle
|
||||
|
||||
|
@ -1,76 +0,0 @@
|
||||
"""
|
||||
Construction
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2022 Project Author name guillermo.gutierrezmorote@concordia.ca
|
||||
Code contributors: Peter Yefi peteryefi@gmail.com
|
||||
"""
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from flask import Response, request
|
||||
from flask_restful import Resource
|
||||
from hub_api.config import Config
|
||||
from city_model_structure.building_demand.layer import Layer
|
||||
from city_model_structure.building_demand.material import Material
|
||||
from persistence.models import UserRoles
|
||||
from hub_api.helpers.auth import role_required
|
||||
|
||||
|
||||
class Construction(Resource, Config):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@role_required([UserRoles.Admin.value, UserRoles.Hub_Reader.value])
|
||||
def put(self, city_id):
|
||||
city = self.get_city(city_id)
|
||||
try:
|
||||
building_names = request.json['building_names']
|
||||
constructions = request.json['constructions']
|
||||
for construction in constructions:
|
||||
construction_type = construction['type']
|
||||
layers = construction['layers']
|
||||
for building_name in building_names:
|
||||
for building in city.buildings:
|
||||
if building.human_readable_name != building_name:
|
||||
continue
|
||||
for internal_zone in building.internal_zones:
|
||||
for thermal_zone in internal_zone.thermal_zones:
|
||||
thermal_zone.additional_thermal_bridge_u_value = request.json['extra_loses_due_to_thermal_bridges']
|
||||
thermal_zone.indirect_heated_area_ratio = request.json['indirect_heated_ratio']
|
||||
thermal_zone.infiltration_rate_system_on = request.json['infiltration_rate_for_ventilation_system_on']
|
||||
thermal_zone.infiltration_rate_system_off = request.json['infiltration_rate_for_ventilation_system_off']
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
if thermal_boundary.parent_surface.type == construction_type:
|
||||
_layers = []
|
||||
for layer in layers:
|
||||
_layer = Layer()
|
||||
thermal_resistance = layer['material']['thermal_resistance']
|
||||
conductivity = layer['material']['conductivity']
|
||||
density = layer['material']['density']
|
||||
specific_heat = layer['material']['specific_heat']
|
||||
_layer.thickness = layer['thickness']
|
||||
_material = Material()
|
||||
_material.id = layer['material']['id']
|
||||
_material.name = layer['material']['name']
|
||||
_material.solar_absorptance = layer['material']['solar_absorptance']
|
||||
_material.thermal_absorptance = layer['material']['thermal_absorptance']
|
||||
_material.visible_absorptance = layer['material']['visible_absorptance']
|
||||
_material.no_mass = layer['material']['no_mass']
|
||||
_material.thermal_resistance = (thermal_resistance if thermal_resistance != '' else None)
|
||||
_material.conductivity = (conductivity if conductivity != '' else None)
|
||||
_material.density = (density if density != '' else None)
|
||||
_material.specific_heat = (specific_heat if specific_heat != '' else None)
|
||||
_layer.material = _material
|
||||
_layers.append(_layer)
|
||||
thermal_boundary.layers = _layers
|
||||
if 'window' in construction.keys():
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
thermal_opening.frame_ratio = construction['window']['frame_ratio']
|
||||
thermal_opening.g_value = construction['window']['g_value']
|
||||
thermal_opening.overall_u_value = construction['window']['overall_u_value']
|
||||
response = {'result': 'succeed'}
|
||||
except KeyError as ex:
|
||||
response = {'error': f'Mandatory parameter {ex} is missing'}
|
||||
return Response(json.dumps(response), status=400)
|
||||
|
||||
return Response(json.dumps(response), status=200)
|
@ -6,10 +6,10 @@ from geomeppy import IDF
|
||||
import os
|
||||
import glob
|
||||
import hub_api.helpers.session_helper as sh
|
||||
import helpers.constants as cte
|
||||
import hub.helpers.constants as cte
|
||||
import csv
|
||||
from hub_api.helpers.auth import role_required
|
||||
from persistence.models import UserRoles
|
||||
from hub.persistence.models import UserRoles
|
||||
from hub_api.config import Config
|
||||
|
||||
|
||||
|
@ -14,79 +14,6 @@ greenery_catalog = None
|
||||
construction_catalog = None
|
||||
usage_catalog = None
|
||||
|
||||
roofs_associated_to_percentage = {'10': ['BuildingAX5th:ZoneX56Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_1',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_2',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_3',
|
||||
'BuildingAX3rd:ZoneX76Xspace_Roof_1_0_0'],
|
||||
'20': ['BuildingBX2nd:Airbnb2_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_1'],
|
||||
'30': ['BuildingBX2nd:Airbnb_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX53Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_0'],
|
||||
'40': ['AdditionalBuildings:ZoneX73Xspace_Roof_1_0_2',
|
||||
'BuildingBX2nd:Airbnb_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_4',
|
||||
'BuildingAX5th:ZoneX54Xspace_Roof_1_0_0'],
|
||||
'50': ['BuildingBX2nd:Airbnb2_Roof_1_0_0',
|
||||
'BuildingBX2nd:Airbnb_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX53Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_1',
|
||||
'BuildingAX5th:ZoneX55Xspace_Roof_1_0_0'],
|
||||
'60': ['BuildingBX2nd:Airbnb2_Roof_1_0_0',
|
||||
'BuildingBX2nd:Airbnb_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX53Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX54Xspace_Roof_1_0_0'],
|
||||
'70': ['BuildingBX2nd:Airbnb2_Roof_1_0_0',
|
||||
'BuildingBX2nd:Airbnb_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX56Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX53Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_1',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_2',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_3',
|
||||
'BuildingAX5th:ZoneX54Xspace_Roof_1_0_0',
|
||||
'BuildingAX3rd:ZoneX76Xspace_Roof_1_0_0'],
|
||||
'80': ['BuildingCX2nd:ZoneX41Xspace_Roof_1_0_0',
|
||||
'BuildingBX2nd:Corridor_Roof_1_0_0',
|
||||
'BuildingBX2nd:Airbnb2_Roof_1_0_0',
|
||||
'BuildingBX2nd:Airbnb_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX53Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_2',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_4',
|
||||
'BuildingAX5th:ZoneX54Xspace_Roof_1_0_0'],
|
||||
'90': ['AdditionalBuildings:ZoneX73Xspace_Roof_1_0_0',
|
||||
'AdditionalBuildings:ZoneX73Xspace_Roof_1_0_1',
|
||||
'AdditionalBuildings:ZoneX73Xspace_Roof_1_0_2',
|
||||
'BuildingCX2nd:ZoneX41Xspace_Roof_1_0_0',
|
||||
'BuildingBX2nd:Corridor_Roof_1_0_0',
|
||||
'BuildingBX2nd:Airbnb2_Roof_1_0_0',
|
||||
'BuildingBX2nd:Airbnb_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX53Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_4',
|
||||
'BuildingAX5th:ZoneX54Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX55Xspace_Roof_1_0_0'],
|
||||
'100': ['AdditionalBuildings:ZoneX73Xspace_Roof_1_0_0',
|
||||
'AdditionalBuildings:ZoneX73Xspace_Roof_1_0_1',
|
||||
'AdditionalBuildings:ZoneX73Xspace_Roof_1_0_2',
|
||||
'BuildingCX2nd:ZoneX41Xspace_Roof_1_0_0',
|
||||
'BuildingBX2nd:Corridor_Roof_1_0_0',
|
||||
'BuildingBX2nd:Airbnb2_Roof_1_0_0',
|
||||
'BuildingBX2nd:Airbnb_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX56Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX53Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_0',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_1',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_2',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_3',
|
||||
'BuildingAX5th:Corridor_Roof_1_0_4',
|
||||
'BuildingAX5th:ZoneX54Xspace_Roof_1_0_0',
|
||||
'BuildingAX5th:ZoneX55Xspace_Roof_1_0_0',
|
||||
'BuildingAX3rd:ZoneX76Xspace_Roof_1_0_0'],
|
||||
}
|
||||
|
||||
|
||||
class SessionData:
|
||||
def __init__(self, session):
|
||||
|
Loading…
Reference in New Issue
Block a user