Skip to content

fix(data): give each OSM area the IRI of its own way or relation (#160) - #161

Merged
MathiasVDA merged 2 commits into
mainfrom
b5/osm-iris
Dec 3, 2026
Merged

MathiasVDA merged 2 commits into
mainfrom
b5/osm-iris

Conversation

@MathiasVDA

@MathiasVDA MathiasVDA commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Mathias · project thread

Closes #160

What and why

osmium's --add-unique-id=type_id does not give areas their OSM id. It numbers an area a<n>, where n is twice the id for a closed way, or twice the id plus one for a multipolygon relation.

Both converters took n as a way id. So an area could get the IRI of another way: a246, from way 123, became way/246. Features then shared an IRI and had two classes and two geometries. That is how Matdata-eu/tripletrail#340's land-use side was given up at 1B triples.

The changes:

  • IRIs. A new bench/v2/data/osm_ids.py maps a<n> to way/<n/2> for even n and to relation/<(n-1)/2> for odd n. Both converters use it.
  • One class per OSM object. osm_scale.py streams, so it can't keep a set of IRIs seen as osm_extract.py does. Instead, it drops the area of a closed way whose line already has a class (a track, a highway), since osmium exports such a way as both line and area.
  • Data version 2. osm_ids.DATA_VERSION is written to:
    • the meta of both converters (osm_extract.py also records shared_iris, the features it left out because their OSM object already had a set);
    • the extract record of each engine's load.json (run_scale.sh) and of the run manifest (runs.py).
  • Comparisons across versions. compare.py treats the same OSM file at another data version as another extract, so answers on it are counted under other_extract. The dashboard's provenance shows data v2 beside the extract, so the site keeps those runs apart. The OSM tabs carry a note on the change.
  • Cached data. run_scale.sh rebuilds cached N-Triples whose meta has an older version.

How it was tested

  • New bench/v2/test_osm_data.py, a small osmium-style GeoJSON sequence covering:

    • an area from a way, an area from a relation, and a way whose id equals the area's raw number: three distinct IRIs, each with one class and one geometry;
    • a closed way tagged as both track and land use: kept as a track only, in set a;
    • the same with a highway and a building: kept as a highway only, in set b.
  • test_compare.py gets a case for another data version of one file. test_dashboard.py checks the extract shown with data v2.

  • Every bench/v2/test_*.py and site/test_summary.py passes. node --check site/app.js and bash -n run_scale.sh are clean.

  • The Norway extract from the bench-data release, before and after:

    features IRIs with >1 geometry with >1 class
    osm_scale.py --set a, before 290,336 3 3
    osm_scale.py --set a, after 290,339 0 0
    osm_extract.py, before 290,336 (3 land-use areas dropped as "seen") 0 0
    osm_extract.py, after 290,339 (shared_iris 0) 0 0

    The 3 land-use areas the old osm_extract.py dropped are back, so osm_norway has 275,718 land-use features instead of 275,715, and its answers may change slightly.

Documentation

  • README.md (OSM Norway)
  • bench/v2/suites/README.md (scale suite data)
  • Dashboard note on the OSM tabs

Generated by Claude Code

osmium numbers areas 2*id (from a way) and 2*id+1 (from a relation), and
the converters took that number as a way id, so an area could get another
way's IRI and features shared IRIs, with two classes and geometries. Both
converters now map areas through data/osm_ids.py, osm_scale.py keeps a
closed way's line class only, and data version 2 is recorded in the meta,
each engine's load.json, compare.py's extract identity and the dashboard.
@MathiasVDA MathiasVDA self-assigned this Dec 3, 2026
@MathiasVDA MathiasVDA added the review:approved Reviewer approved label Dec 3, 2026 — with Claude

Copy link
Copy Markdown
Contributor Author

Approved at 503bcdf. The mapping matches libosmium (an area id is twice the way id, or twice the relation id plus one), every bench/v2/test_*.py and site/test_summary.py pass here, and the acceptance criteria of #160 are met.

One fix I pushed myself (503bcdf): the note on the OSM tabs was shown whatever the results were measured on, so the published version 1 results would have carried a note saying every area has its own IRI. osmDataNote now reads the extract in the provenance: with data v2 it shows the version 2 note, otherwise a note that the results shown are from data version 1 and the next run uses version 2.

I merge it when the checks are green.


Generated by Claude Code

@MathiasVDA
MathiasVDA merged commit 75b641b into main Dec 3, 2026
9 checks passed
@MathiasVDA
MathiasVDA deleted the b5/osm-iris branch December 3, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved Reviewer approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(data): OSM area ids become IRIs of other ways and relations

1 participant