Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heatmap request examples #1908

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/src/core/heatmap_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def generate_final_geojson(grid_ids:np.ndarray, polygons:np.ndarray, calculation
feature["properties"][key] = None
feature["properties"][key + "_class"] = -1
continue
feature["properties"][key] = float(calculation[i])
feature["properties"][key] = round(float(calculation[i]), 2)
feature["properties"][key + "_class"] = int(quantiles[key][i])
features.append(feature)
geojson["type"] = "FeatureCollection"
Expand Down
143 changes: 82 additions & 61 deletions app/api/src/schemas/heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ def heatmap_config_schema(cls, value, values):

return value

# TODO: Remove this validator when we have a proper schema for heatmap_config
@validator("heatmap_config", pre=True)
def pass_poi_to_heatmap_config(cls, value):
poi = value.get("poi")
if poi:
return poi
else:
return value


"""
Body of the request
Expand All @@ -156,9 +165,11 @@ def heatmap_config_schema(cls, value, values):
"analysis_unit": "hexagon",
"resolution": 10,
"heatmap_config": {
"atm": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"bar": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"gym": {"weight": 1, "sensitivity": 350000, "max_traveltime": 5},
"poi": {
"atm": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"bar": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"gym": {"weight": 1, "sensitivity": 350000, "max_traveltime": 5},
},
},
},
},
Expand All @@ -177,9 +188,11 @@ def heatmap_config_schema(cls, value, values):
"analysis_unit": "hexagon",
"resolution": 9,
"heatmap_config": {
"atm": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"bar": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"gym": {"weight": 1, "sensitivity": 350000, "max_traveltime": 5},
"poi": {
"atm": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"bar": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"gym": {"weight": 1, "sensitivity": 350000, "max_traveltime": 5},
},
},
},
},
Expand All @@ -198,9 +211,11 @@ def heatmap_config_schema(cls, value, values):
"analysis_unit": "hexagon",
"resolution": 6,
"heatmap_config": {
"atm": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"bar": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"gym": {"weight": 1, "sensitivity": 350000, "max_traveltime": 5},
"poi": {
"atm": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"bar": {"weight": 1, "sensitivity": 250000, "max_traveltime": 5},
"gym": {"weight": 1, "sensitivity": 350000, "max_traveltime": 5},
},
},
},
},
Expand All @@ -219,52 +234,54 @@ def heatmap_config_schema(cls, value, values):
"analysis_unit": "hexagon",
"resolution": 10,
"heatmap_config": {
"atm": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bar": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"gym": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"pub": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bank": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"cafe": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"fuel": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"park": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"yoga": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"hotel": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bakery": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"cinema": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"forest": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"museum": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"butcher": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"dentist": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"nursery": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bus_stop": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"pharmacy": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"post_box": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"fast_food": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"gymnasium": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"nightclub": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"recycling": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"tram_stop": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"playground": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"realschule": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"restaurant": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"car_sharing": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"convenience": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"grundschule": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"hypermarket": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"marketplace": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"post_office": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"supermarket": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bike_sharing": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"discount_gym": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"kindergarten": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"rail_station": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"subway_entrance": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"charging_station": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"organic_supermarket": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"discount_supermarket": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"general_practitioner": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"swimming_pool_outdoor": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"hauptschule_mittelschule": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"poi": {
"atm": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bar": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"gym": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"pub": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bank": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"cafe": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"fuel": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"park": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"yoga": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"hotel": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bakery": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"cinema": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"forest": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"museum": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"butcher": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"dentist": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"nursery": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bus_stop": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"pharmacy": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"post_box": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"fast_food": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"gymnasium": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"nightclub": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"recycling": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"tram_stop": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"playground": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"realschule": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"restaurant": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"car_sharing": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"convenience": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"grundschule": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"hypermarket": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"marketplace": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"post_office": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"supermarket": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bike_sharing": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"discount_gym": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"kindergarten": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"rail_station": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"subway_entrance": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"charging_station": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"organic_supermarket": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"discount_supermarket": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"general_practitioner": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"swimming_pool_outdoor": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"hauptschule_mittelschule": {"weight": 1, "max_count": 1, "max_traveltime": 5},
},
},
},
},
Expand All @@ -283,9 +300,11 @@ def heatmap_config_schema(cls, value, values):
"analysis_unit": "hexagon",
"resolution": 9,
"heatmap_config": {
"atm": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bar": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"gym": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"poi": {
"atm": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bar": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"gym": {"weight": 1, "max_count": 1, "max_traveltime": 5},
},
},
},
},
Expand All @@ -304,9 +323,11 @@ def heatmap_config_schema(cls, value, values):
"analysis_unit": "hexagon",
"resolution": 6,
"heatmap_config": {
"atm": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bar": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"gym": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"poi": {
"atm": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"bar": {"weight": 1, "max_count": 1, "max_traveltime": 5},
"gym": {"weight": 1, "max_count": 1, "max_traveltime": 5},
},
},
},
},
Expand Down