complete the meb results
This commit is contained in:
parent
921034a884
commit
f5b48fee4e
@ -23,7 +23,7 @@ from hub_api.helpers.session_helper import refresh_session
|
||||
class InselMonthlyEnergyBalance(Resource, Config):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._extensions = ['.geojson', '.citygml']
|
||||
self._extensions = ['.geojson', '.gml']
|
||||
self._tmp_path = (Path(__file__).parent / 'tmp').resolve()
|
||||
self._city = None
|
||||
|
||||
@ -36,7 +36,7 @@ class InselMonthlyEnergyBalance(Resource, Config):
|
||||
height_field = request.form.get('height_field')
|
||||
year_of_construction_field = request.form.get('year_of_construction_field')
|
||||
function_field = request.form.get('function_field')
|
||||
function_dictionary = self._dictionaries[request.form.get('function_dictionary_name')]
|
||||
function_dictionary = self._dictionaries[request.form.get('function_to_hub')]
|
||||
return GeometryFactory('geojson',
|
||||
path=file_path,
|
||||
height_field=height_field,
|
||||
@ -47,17 +47,21 @@ class InselMonthlyEnergyBalance(Resource, Config):
|
||||
return None
|
||||
|
||||
def _citygml(self, file_path):
|
||||
try:
|
||||
# try:
|
||||
year_of_construction_field = request.form.get('year_of_construction_field')
|
||||
if year_of_construction_field is '':
|
||||
year_of_construction_field = None
|
||||
function_field = request.form.get('function_field')
|
||||
function_dictionary = self._dictionaries[request.form.get('function_dictionary_name')]
|
||||
if function_field is '':
|
||||
function_field = None
|
||||
function_dictionary = self._dictionaries[request.form.get('function_to_hub')]
|
||||
return GeometryFactory('citygml',
|
||||
path=file_path,
|
||||
year_of_construction_field=year_of_construction_field,
|
||||
function_field=function_field,
|
||||
function_to_hub=function_dictionary).city
|
||||
except KeyError:
|
||||
return None
|
||||
# except KeyError:
|
||||
# return None
|
||||
|
||||
def post(self):
|
||||
"""
|
||||
@ -67,6 +71,7 @@ class InselMonthlyEnergyBalance(Resource, Config):
|
||||
token = request.headers.get('token', None)
|
||||
application_uuid = request.headers.get('application-uuid', None)
|
||||
_session = refresh_session(session_id, token, application_uuid)
|
||||
_session = {'token': token}
|
||||
if _session is None:
|
||||
return Response(json.dumps({'error': 'unauthorized'}), status=403)
|
||||
else:
|
||||
@ -114,7 +119,27 @@ class InselMonthlyEnergyBalance(Resource, Config):
|
||||
'monthly_lighting_peak_load': building.lighting_peak_load[cte.MONTH],
|
||||
'yearly_lighting_peak_load': building.lighting_peak_load[cte.YEAR],
|
||||
'monthly_appliances_peak_load': building.appliances_peak_load[cte.MONTH],
|
||||
'yearly_appliances_peak_load': building.appliances_peak_load[cte.YEAR]
|
||||
'yearly_appliances_peak_load': building.appliances_peak_load[cte.YEAR],
|
||||
'monthly_cooling_peak_load': building.cooling_peak_load[cte.MONTH],
|
||||
'yearly_cooling_peak_load': building.cooling_peak_load[cte.YEAR],
|
||||
'monthly_heating_peak_load': building.heating_peak_load[cte.MONTH],
|
||||
'yearly_heating_peak_load': building.heating_peak_load[cte.YEAR],
|
||||
'monthly_cooling_consumption': building.cooling_consumption[cte.MONTH],
|
||||
'yearly_cooling_consumption': building.cooling_consumption[cte.YEAR],
|
||||
'monthly_heating_consumption': building.heating_consumption[cte.MONTH],
|
||||
'yearly_heating_consumption': building.heating_consumption[cte.YEAR],
|
||||
'monthly_lighting_electrical_demand': building.lighting_electrical_demand[cte.MONTH],
|
||||
'yearly_lighting_electrical_demand': building.lighting_electrical_demand[cte.YEAR],
|
||||
'monthly_appliances_electrical_demand': building.appliances_electrical_demand[cte.MONTH],
|
||||
'yearly_appliances_electrical_demand': building.appliances_electrical_demand[cte.YEAR],
|
||||
'monthly_onsite_electrical_production': building.onsite_electrical_production[cte.MONTH],
|
||||
'yearly_onsite_electrical_production': building.onsite_electrical_production[cte.YEAR],
|
||||
'monthly_domestic_hot_water_consumption': building.domestic_hot_water_consumption[cte.MONTH],
|
||||
'yearly_domestic_hot_water_consumption': building.domestic_hot_water_consumption[cte.YEAR],
|
||||
'monthly_domestic_hot_water_demand': building.domestic_hot_water_heat_demand[cte.MONTH],
|
||||
'yearly_domestic_hot_water_demand': building.domestic_hot_water_heat_demand[cte.YEAR],
|
||||
'monthly_distribution_systems_electrical_consumption': building.domestic_hot_water_consumption[cte.MONTH],
|
||||
'yearly_distribution_systems_electrical_consumption': building.domestic_hot_water_consumption[cte.MONTH]
|
||||
}
|
||||
shutil.rmtree(tmp_path)
|
||||
return Response(json.dumps({'result': 'succeed', 'results': results}), status=200, headers=response_token)
|
||||
|
Loading…
Reference in New Issue
Block a user