"""Feature registry and dispatch helpers for scene assembly phases.""" from collections import namedtuple FeatureHandler = namedtuple("FeatureHandler", ("name", "matches", "handle")) def dispatch_ways(ways, projector, handlers): """Dispatch OSM ways to the first matching handler, preserving order.""" for way in ways: coords = way["coords"] if not any(projector.inside(c) for c in coords): continue ring = projector.ring(coords) tag = way["tags"] for handler in handlers: if handler.matches(way, tag, ring): handler.handle(way, tag, ring) break