This commit is contained in:
Andras Schmelczer 2026-07-12 21:31:13 +01:00
parent ca771a7edf
commit d7f844d566
12 changed files with 198 additions and 251 deletions

View file

@ -56,6 +56,22 @@ DYNAMIC_FILTER_ALL_GROUPS = {"Public Transport", "Leisure", "Health"}
DYNAMIC_FILTER_COUNT_THRESHOLD_GROUPS = {"Groceries"}
DYNAMIC_FILTER_EXCLUDED_CATEGORIES = {"Park"}
# Combined "nearest of any rail mode" distance: the distance to the closest of a
# Rail station, Tube station, DLR station, or Tram & Metro stop. Materialized as
# its own real column so the server loads it like any other per-category
# distance. min_distance_per_postcode already supports multi-category groups, so
# this is a genuine nearest-of-the-union query (identical to the per-mode
# minimum). Distance only: a combined "within Xkm" count is not meaningful, so
# it is intentionally omitted from the count groups.
COMBINED_STATION_GROUP_KEY = "poi_any_station"
COMBINED_STATION_DISPLAY_NAME = "Any station"
COMBINED_STATION_SOURCE_CATEGORIES = [
"Rail station",
"Tube station",
"DLR station",
"Tram & Metro stop",
]
def _poi_category_slug(category: str) -> str:
ascii_text = (
@ -227,10 +243,21 @@ def main():
dynamic_counts_5km = count_pois_per_postcode(
postcodes, pois, groups=poi_category_groups, radius_km=5
)
# Distances additionally include the combined "Any station" group (nearest of
# any rail mode). It is distance-only, so it is added here but not to the
# 2km/5km count groups above.
distance_groups = {
**poi_category_groups,
COMBINED_STATION_GROUP_KEY: COMBINED_STATION_SOURCE_CATEGORIES,
}
distance_display_names = {
**poi_display_names,
COMBINED_STATION_GROUP_KEY: COMBINED_STATION_DISPLAY_NAME,
}
dynamic_distances = min_distance_per_postcode(
postcodes, pois, groups=poi_category_groups
postcodes, pois, groups=distance_groups
)
dynamic_renames = _dynamic_poi_metric_renames(poi_display_names)
dynamic_renames = _dynamic_poi_metric_renames(distance_display_names)
dynamic_counts_2km = dynamic_counts_2km.rename(
{k: v for k, v in dynamic_renames.items() if k in dynamic_counts_2km.columns}
)