Add feature registry dispatch
This commit is contained in:
20
blender/osmassets/features.py
Normal file
20
blender/osmassets/features.py
Normal file
@@ -0,0 +1,20 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user