def post(self): """ Returns the statistics for specific layers, hectares and year :return: """ #try: # Entries wrong_parameter = [] layersPayload = api.payload['layers'] try: year = api.payload['year'] except: wrong_parameter.append('year') try: layersPayload = api.payload['layers'] except: wrong_parameter.append('layers') try: areas = api.payload['areas'] for test_area in areas: try: for test_point in test_area['points']: try: test_lng = test_point['lng'] except: wrong_parameter.append('lng') try: test_lat = test_point['lat'] except: wrong_parameter.append('lat') except: wrong_parameter.append('points') except: wrong_parameter.append('areas') # raise exception if parameters are false if len(wrong_parameter) > 0: exception_message = '' for i in range(len(wrong_parameter)): exception_message += wrong_parameter[i] if (i != len(wrong_parameter) - 1): exception_message += ', ' raise ParameterException(str(exception_message)) output, noDataLayers = LayersStats.run_stat(api.payload) #print ("output hectare ",output) #output return { "layers": output, "no_data_layers": noDataLayers, "no_table_layers": noDataLayers }
def post(self): """ Returns the heat load data by nuts or lau :return: """ # Entries wrong_parameter = [] try: year = api.payload['year'] except: wrong_parameter.append('year') try: nuts = api.payload['nuts'] except: wrong_parameter.append('nuts') # raise exception if parameters are false if len(wrong_parameter) > 0: exception_message = '' for i in range(len(wrong_parameter)): exception_message += wrong_parameter[i] if i != len(wrong_parameter) - 1: exception_message += ', ' raise ParameterException(exception_message + '') # Stop execution if nuts list is empty if not nuts: return nuts = helper.nuts_array_to_string(nuts) if 'month' in api.payload.keys(): month = api.payload["month"] else: month = 0 if 'day' in api.payload.keys(): day = api.payload["day"] else: day = 0 output = {} nuts_level = api.payload["scale_level"] """ try: """ output = HeatLoadProfile.heatloadprofile_nuts_lau( nuts=nuts, year=year, month=month, day=day, nuts_level=nuts_level) """ except Exception as e: raise IntersectionException """ return output
def post(self): """ Returns the statistics for specific layers, area and year :return: """ #try: # Entries wrong_parameter = [] try: year = api.payload['year'] except: wrong_parameter.append('year') try: layersPayload = api.payload['layers'] except: wrong_parameter.append('layers') try: nuts = api.payload['nuts'] except: wrong_parameter.append('nuts') # raise exception if parameters are false if len(wrong_parameter) > 0: exception_message = '' for i in range(len(wrong_parameter)): exception_message += wrong_parameter[i] if i != len(wrong_parameter) - 1: exception_message += ', ' raise ParameterException(exception_message + '') # Stop execution if layers list or nuts list is empty if not layersPayload or not nuts: return # Get type output, noDataLayers = LayersStats.run_stat(api.payload) # output return { "layers": output, "no_data_layers": noDataLayers, "no_table_layers": noDataLayers }
def post(self): """ Returns the statistics for specific layers, area and year :return: """ # Entries wrong_parameter = [] try: nuts = api.payload['nuts'] except: wrong_parameter.append('nuts') # raise exception if parameters are false if len(wrong_parameter) > 0: exception_message = '' for i in range(len(wrong_parameter)): exception_message += wrong_parameter[i] if (i != len(wrong_parameter) - 1): exception_message += ', ' raise ParameterException(str(exception_message)) res = ElectricityMix.getEnergyMixNutsLau(adapt_nuts_list(nuts)) return res
def post(self): """ Returns the statistics for specific layers, area and year :return: """ # Entries wrong_parameter = [] try: year = api.payload['year'] except: wrong_parameter.append('year') try: nuts = api.payload['nuts'] except: wrong_parameter.append('nuts') # raise exception if parameters are false if len(wrong_parameter) > 0: exception_message = '' for i in range(len(wrong_parameter)): exception_message += wrong_parameter[i] if i != len(wrong_parameter) - 1: exception_message += ', ' raise ParameterException(exception_message + '') nuts_level = api.payload['scale_level'] # Stop execution if nuts list is empty if not nuts: return nuts = helper.nuts_array_to_string(nuts) output = {} output = HeatLoadProfile.duration_curve_nuts_lau(year=year, nuts=nuts, nuts_level=nuts_level) return {"points": output}
def post(self): """ Returns the heat load data by hectare :return: """ # Entries wrong_parameter = [] try: year = api.payload['year'] except: wrong_parameter.append('year') try: areas = api.payload['areas'] for test_area in areas: try: for test_point in test_area['points']: try: test_lng = test_point['lng'] except: wrong_parameter.append('lng') try: test_lat = test_point['lat'] except: wrong_parameter.append('lat') except: wrong_parameter.append('points') except: wrong_parameter.append('areas') # raise exception if parameters are false if len(wrong_parameter) > 0: exception_message = '' for i in range(len(wrong_parameter)): exception_message += wrong_parameter[i] if i != len(wrong_parameter) - 1: exception_message += ', ' raise ParameterException(exception_message + '') # Stop execution if areas list is empty if not areas: return if 'month' in api.payload.keys(): month = api.payload["month"] else: month = 0 if 'day' in api.payload.keys(): day = api.payload["day"] else: day = 0 polyArray = [] output = {} # TODO: this part must be one methods same in /aggregate/duration_curve/hectares Rules 1 NO DUPLICATE # convert to polygon format for each polygon and store them in polyArray for polygon in areas: po = shapely_geom.Polygon([[p['lng'], p['lat']] for p in polygon['points']]) polyArray.append(po) # convert array of polygon into multipolygon multipolygon = shapely_geom.MultiPolygon(polyArray) # geom = "SRID=4326;{}".format(multipolygon.wkt) geom = multipolygon.wkt res = HeatLoadProfile.heatloadprofile_hectares(year=year, month=month, day=day, geometry=geom) return res
def post(self): """ Returns the statistics for specific layers, area and year :return: """ #Entries wrong_parameter = [] try: year = api.payload['year'] except: wrong_parameter.append('year') try: areas = api.payload['areas'] for test_area in areas: try: for test_point in test_area['points']: try: test_lng = test_point['lng'] except: wrong_parameter.append('lng') try: test_lat = test_point['lat'] except: wrong_parameter.append('lat') except: wrong_parameter.append('points') except: wrong_parameter.append('areas') # raise exception if parameters are false if len(wrong_parameter) > 0: exception_message = '' for i in range(len(wrong_parameter)): exception_message += wrong_parameter[i] if (i != len(wrong_parameter) - 1): exception_message += ', ' raise ParameterException(exception_message + '') # Stop execution if areas list is empty polyArray = [] output = {} # TODO: this part must be one methods same in /aggregate/hectares Rules 1 NO DUPLICATE # convert to polygon format for each polygon and store them in polyArray for polygon in areas: po = shapely_geom.Polygon([[p['lng'], p['lat']] for p in polygon['points']]) polyArray.append(po) # convert array of polygon into multipolygon multipolygon = shapely_geom.MultiPolygon(polyArray) # geom = "SRID=4326;{}".format(multipolygon.wkt) geom = multipolygon.wkt #try: output = HeatLoadProfile.duration_curve_hectares(year=year, geometry=geom) #except: # raise IntersectionException() return {"points": output}