Skip to content

feat(wikidata): Count OSM features and names per brand - #928

Merged
brawer merged 2 commits into
mainfrom
osm-brand-totals
Nov 11, 2026
Merged

brawer merged 2 commits into
mainfrom
osm-brand-totals

Conversation

@brawer

@brawer brawer commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Requested by Sascha · project thread

Fourth of the PRs planned in #924, after #927. collect_wikidata_ids already visits every ATP and OSM feature with a brand:wikidata, operator:wikidata or network:wikidata tag. It now also writes two files for the spider stats of PR 5. Nothing is published yet.

osm-brands.tsv: OSM features per Wikidata ID, country and main category, such as Q680727 CH shop=supermarket 1234. The category is the one contact::main_category gives (shop, amenity, tourism, leisure, healthcare, craft, office), or empty, as for transit stops. A feature that names the same ID twice, such as by brand:wikidata and operator:wikidata, counts once. This lets the spider stats compare ATP's count for a brand with OSM's, per country.

brand-names.tsv: one display name per Wikidata ID and key (brand, operator or network, from the tag that goes with the Wikidata tag): the most common name in Latin script, or if there is none, the most common one, with how often OSM and ATP use it. That is enough to tell brands apart in an internal tool, without a name per country. Names count only where the Wikidata tag has a single ID, since with Q1;Q2 there's no telling which name goes with which. ATP names are included so that brands only ATP has get a name too. Tabs and line breaks in names become spaces.

Cost. The country of an OSM feature comes from its centroid, so the features with a Wikidata tag now get their geometry decoded, as send_deletion_candidates already does for unmatched ones. ATP places need no country. Both files are rebuilt when they're missing, so an existing workdir runs this step again.

docs/TECHNICAL_DESIGN.md describes the two files.

Testing. New unit tests for the totals (merging, counting an ID once per feature, names with several IDs, preferring Latin script) and for both files from collect_wikidata_ids on the ATP fixture. cargo test --lib, cargo clippy --all-targets -- -D warnings and cargo fmt pass. CI runs the integration tests, since they need tippecanoe.


https://claude.ai/code/session_01Ttfb2LhDRExioXkdHbxLno


Generated by Claude Code

collect_wikidata_ids already visits every ATP and OSM feature with a
brand:wikidata, operator:wikidata or network:wikidata tag. It now also
writes two files for the spider stats:

- osm-brands.tsv: OSM features per Wikidata ID, country and main
  category (such as shop=supermarket). A feature that names the same
  ID twice counts once.
- brand-names.tsv: the three most common brand, operator or network
  names per Wikidata ID, country and key, with how often OSM and ATP
  use each. Names count only where the Wikidata tag has a single ID.

The country of an OSM feature comes from its centroid, so features
with a Wikidata tag now get their geometry decoded.

Part of #924.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ttfb2LhDRExioXkdHbxLno
@brawer brawer self-assigned this Nov 11, 2026
@github-actions github-actions Bot added the enhancement New feature or request label Nov 11, 2026
The names are only for telling brands apart in the spider stats, so
brand-names.tsv now has one name per Wikidata ID and key, not three
per country: the most common name in Latin script, or else the most
common one. ATP places no longer need their country looked up.
osm-brands.tsv keeps its countries, so the spider stats can compare a
per-country spider with OSM in that country.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ttfb2LhDRExioXkdHbxLno
@brawer
brawer merged commit 9289cb8 into main Nov 11, 2026
6 checks passed
@brawer
brawer deleted the osm-brand-totals branch November 11, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants