Commit 06421a92 authored by Eric Duminil's avatar Eric Duminil
Browse files

OSM: some widths are given with units

parent 770caa5b
...@@ -109,17 +109,19 @@ def set_plot(bounds: Bounds, to_local_coordinates): ...@@ -109,17 +109,19 @@ def set_plot(bounds: Bounds, to_local_coordinates):
return ax return ax
def get_default_widths(ways: list) -> dict[str, float] : def get_default_widths(ways: list) -> dict[str, float]:
"""Check existing OSM highways, and extract the most common width for each type""" """Check existing OSM highways, and extract the most common width for each type"""
width_counters = {} width_counters = {}
for way in ways: for way in ways:
width = float(way.tags.get("width", 0)) # NOTE: Some widths are written with units, so try to remove [m] first.
# TODO: use regex instead
width = float(way.tags.get("width", '0').replace('m', ''))
way_type = way.tags.get("highway") way_type = way.tags.get("highway")
if width: if width:
if way_type not in width_counters: if way_type not in width_counters:
width_counters[way_type] = Counter() width_counters[way_type] = Counter()
width_counters[way_type][width] += 1 width_counters[way_type][width] += 1
return {w:c.most_common(1)[0][0] for w, c in width_counters.items()} return {w: c.most_common(1)[0][0] for w, c in width_counters.items()}
def place_trees(forest: Forest, ways: list, region: str, to_local, tree_distance: float, min_distance_2: float) -> Forest: def place_trees(forest: Forest, ways: list, region: str, to_local, tree_distance: float, min_distance_2: float) -> Forest:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment