Skip to content

fix(map_model): add 4-tier building snap cascade for sidewalk-sparse cities - #1179

Open
AlyZaki wants to merge 1 commit into
a-b-street:mainfrom
AlyZaki:fix/buildings-snap-cascade
Open

fix(map_model): add 4-tier building snap cascade for sidewalk-sparse cities#1179
AlyZaki wants to merge 1 commit into
a-b-street:mainfrom
AlyZaki:fix/buildings-snap-cascade

Conversation

@AlyZaki

@AlyZaki AlyZaki commented May 16, 2026

Copy link
Copy Markdown

make_all_buildings() calls match_points_to_lanes with |l| l.is_walkable() and a 1km radius.
In cities where sidewalks and footways aren't mapped in OSM, this drops every building with no
walkable lane within 1km. That's not a fringe case — in a lot of cities outside Western Europe and
North America, OSM mapping has focused on roads and POIs, not pedestrian infrastructure. Sidewalk
coverage can be under 1%.

The result is that entire neighborhoods lose their buildings in the snap step, which breaks
pedestrian trip generation and density analysis for the whole map.

Fix

New snap_buildings_resilient() that cascades through four strategies:

Tier Radius Filter Log level
1 30m is_walkable() — (normal case)
2 80m is_walkable() INFO
3 150m !is_light_rail() — road edge WARN
4 1km !is_light_rail() — stub WARN

Buildings only drop if all four tiers fail. The log output shows exactly how many buildings needed
each tier, so you can see at a glance what the OSM sidewalk coverage is like for a given city.

No new dependencies. The function reuses match_points_to_lanes internally. Tested against Cairo urban core where sidewalk mapping coverage is <1%.


Developed while importing Cairo urban core OSM data for a city simulation research project at Egypt University of Informatics.

…cities

make_all_buildings() calls match_points_to_lanes with |l| l.is_walkable()
and a 1km radius. In cities where sidewalks and footways aren't mapped in
OSM this drops every building with no walkable lane within 1km — common in
cities where mapping focus has been on roads rather than pedestrian infra.

Add snap_buildings_resilient() which cascades through four strategies:
  Tier 1: 30m  nearest sidewalk/footway  (same as existing, strict)
  Tier 2: 80m  extended sidewalk search
  Tier 3: 150m any non-light-rail lane   (road edge, no sidewalk required)
  Tier 4: 1km  stub snap to distant road

Each tier logs at INFO/WARN so the import summary shows how many buildings
needed degraded snapping. Buildings only drop if all four tiers fail.

Tested against Cairo urban core where sidewalk mapping coverage is <1%.
@dabreegster

Copy link
Copy Markdown
Collaborator

This will break invariants in the traffic sim layer (related to SidewalkSpot::building, and https://a-b-street.github.io/docs/tech/trafficsim/trips.html partly documents this).

The inferred_sidewalks config is intended to deal with cases where separate footpaths aren't explicitly tagged in OSM. I haven't worked on any of this in a while, so I've forgotten some details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants