Modern Apps git

← Modern-Apps.git

scripts/maps: bake maxspeed source-layer into v5 pmtiles

Commit
d0315d3406aa3eb8d0aa5960235ce8ea876dafa4
Author
vayun-mathur <[email protected]>
When
2026-08-16 23:46 UTC (3 months ago)
Parents
e556122

Diff

scripts/maps/README.md
diff --git a/scripts/maps/README.md b/scripts/maps/README.mdindex 6fd547d3a0..50aa53b153 100644--- a/scripts/maps/README.md+++ b/scripts/maps/README.md@@ -91,7 +91,9 @@ base is reused verbatim. P13 points `MaxspeedSource.PMTILES_URL` at v5.pmtiles.   * `highway=traffic_signals` → `traffic_signals` * **Maxspeed** — OpenStreetMap. Ways carrying a `maxspeed` (or   `maxspeed:forward`/`maxspeed:backward`) tag; the raw value is kept verbatim so-  the app parses `mph`/`km/h`/bare numbers itself.+  the app parses `mph`/`km/h`/bare numbers itself. Non-numeric OSM values+  (`none`, `signals`, `walk`, etc.) are also passed through raw — the app-side+  parser (`MaxspeedSource`) decides how to render them. * **Admin borders**:   * country + region → **Natural Earth 10m** (`ne_10m_admin_0_countries`,     `ne_10m_admin_1_states_provinces`). Chosen because the current `.fgb` are@@ -239,12 +241,13 @@ passes: ``` $ python3 scripts/maps/test/test_normalize.py ...-34 passed, 0 failed+37 passed, 0 failed ```  This validates: all five safety `kind` classifications (incl. DeFlock ALPR detection), maxspeed value passthrough (mph/km/h/bare + `maxspeed:forward`-fallback, lines only), non-safety/non-point features dropped, `admin_level`+fallback + non-numeric `none`/`walk`/`signals` raw passthrough, lines only),+non-safety/non-point features dropped, `admin_level` mapping (2/4/8), `ISO_A2` / `iso_3166_2` preservation, county-vs-city `admin_level` filtering, and that every emitted line is valid GeoJSON (tippecanoe input). Run the metro dry run above on a box with the toolchain
scripts/maps/test/fixtures/maxspeed_sample.geojsonseq
diff --git a/scripts/maps/test/fixtures/maxspeed_sample.geojsonseq b/scripts/maps/test/fixtures/maxspeed_sample.geojsonseqindex 2ccc0da76b..aa0462e661 100644--- a/scripts/maps/test/fixtures/maxspeed_sample.geojsonseq+++ b/scripts/maps/test/fixtures/maxspeed_sample.geojsonseq@@ -1,6 +1,9 @@ {"type":"Feature","geometry":{"type":"LineString","coordinates":[[-122.42,37.77],[-122.41,37.78]]},"properties":{"highway":"residential","maxspeed":"25 mph","name":"Main St","id":"way/3001"}} {"type":"Feature","geometry":{"type":"LineString","coordinates":[[-122.41,37.78],[-122.40,37.79]]},"properties":{"highway":"primary","maxspeed":"50","id":"way/3002"}} {"type":"Feature","geometry":{"type":"MultiLineString","coordinates":[[[-122.40,37.79],[-122.39,37.80]]]},"properties":{"highway":"motorway","maxspeed":"100 km/h","id":"way/3003"}}-{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-122.39,37.80],[-122.38,37.81]]},"properties":{"highway":"tertiary","maxspeed:forward":"30 mph","id":"way/3004"}}+{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-122.38,37.81],[-122.37,37.82]]},"properties":{"highway":"tertiary","maxspeed:forward":"30 mph","id":"way/3004"}}+{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-122.45,37.75],[-122.44,37.76]]},"properties":{"highway":"motorway","maxspeed":"none","id":"way/3007"}}+{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-122.44,37.76],[-122.43,37.77]]},"properties":{"highway":"living_street","maxspeed":"walk","id":"way/3008"}}+{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-122.43,37.77],[-122.42,37.78]]},"properties":{"highway":"primary","maxspeed":"signals","id":"way/3009"}} {"type":"Feature","geometry":{"type":"LineString","coordinates":[[-122.38,37.81],[-122.37,37.82]]},"properties":{"highway":"service","id":"way/3005"}} {"type":"Feature","geometry":{"type":"Point","coordinates":[-122.37,37.82]},"properties":{"highway":"speed_camera","maxspeed":"40","id":"node/3006"}}
scripts/maps/test/test_normalize.py
diff --git a/scripts/maps/test/test_normalize.py b/scripts/maps/test/test_normalize.pyindex 0cb7bb6d19..efb0b0327b 100644--- a/scripts/maps/test/test_normalize.py+++ b/scripts/maps/test/test_normalize.py@@ -97,14 +97,18 @@ def test_maxspeed() -> None:     print("maxspeed layer:")     raw = _load(FIX / "maxspeed_sample.geojsonseq")     feats = list(normalize_maxspeed.normalize(normalize_maxspeed.iter_features(raw)))-    # 4 line features with maxspeed; service (no maxspeed) + Point node dropped.-    check("emits 4 line features", len(feats) == 4, f"got {len(feats)}")+    # 7 line features with maxspeed; service (no maxspeed) + Point node dropped.+    check("emits 7 line features", len(feats) == 7, f"got {len(feats)}")     check("all line geometry", all(f["geometry"]["type"] in ("LineString", "MultiLineString") for f in feats))     values = [f["properties"]["maxspeed"] for f in feats]     check("keeps raw mph value", "25 mph" in values)     check("keeps bare number value", "50" in values)     check("keeps km/h value", "100 km/h" in values)     check("falls back to maxspeed:forward", "30 mph" in values)+    # Non-numeric OSM values are passed through raw; the app parser handles them.+    check("passes through 'none' raw", "none" in values)+    check("passes through 'walk' raw", "walk" in values)+    check("passes through 'signals' raw", "signals" in values)     check("every feature has maxspeed property", all(f["properties"].get("maxspeed") for f in feats))     check("no point node leaked", all(f["geometry"]["type"] != "Point" for f in feats))