onthegomap / planetiler

Flexible tool to build planet-scale vector tilesets from OpenStreetMap data fast
Apache License 2.0
1.48k stars 116 forks source link

Prefer name statements over Wikidata labels #679

Open 1ec5 opened 1 year ago

1ec5 commented 1 year ago

Wikidata fetches the label of each linked Wikidata item in each available language:

https://github.com/onthegomap/planetiler/blob/79ba9d925f4a3738a07cc6a6dc4a6ede6d0f5c4b/planetiler-core/src/main/java/com/onthegomap/planetiler/util/Wikidata.java#L98-L102

This is suboptimal because Wikidata labels are technically mainly for labeling items on the Wikidata site. Even though a label usually corresponds to a concept’s common name, it may sometimes contain some modifications to be recognizable on the site. (The closest analogy in OSM would be the name of a route relation that a mapper has optimized for display in the osm.org sidebar or JOSM’s relation list.)

A better alternative is the name (P2561) property. When an item has statements for this property, the query should prefer those statements. If there’s no statement for a given language, it should fall back to the label in that language.

If there are multiple name statements in a given language, the query should prefer the one with preferred rank, or without an end time (P582). Better yet, it should prefer the statement with the object has role (P3831) qualifier set to map label (Q104642575). For example, this will avoid adding an extra “D.C.” disambiguator to Washington, D.C. (which is correct in most written mediums, just not maps).

/ref openmaptiles/openmaptiles-tools#437 https://github.com/ZeLonewolf/openstreetmap-americana/pull/592#discussion_r1035274034

msbarry commented 1 year ago

Thanks @1ec5 - We want the default behavior to match openmaptiles, so I think we'd want to wait for a decision there to replicate it downstream to planetiler-openmaptiles. But if we run into any issues with that or want to do it sooner we can change that behavior in planetiler/planetiler-openmaptiles and enable the behavior change behind a command-line flag.

Also this is helpful: https://github.com/openmaptiles/openmaptiles-tools/issues/437#issuecomment-1742779667

The current query is:

SELECT ?id ?label where {
  VALUES ?id { wd:Q1 wd:Q2 ... } ?id (owl:sameAs* / rdfs:label) ?label
}
1ec5 commented 1 year ago

Out of curiosity, is the owl:sameAs* having a significant impact on the quantity or quality of results? OpenMapTiles doesn’t include that path in its query.