Permanent ID for OSM

Aus Geoinformation HSR
Version vom 22. Juli 2020, 20:01 Uhr von Stefan (Diskussion | Beiträge) (Overpass' Permanent ID)

Wechseln zu: Navigation, Suche
 This is an unofficial proposal for a "OSM permanent ID" (osm_pid) for OpenStreetMap (OSM). 
 See here for a more well known place for discussions. 

Goals and Requirements

The goal is to get an opaque (eventually fixed) length ASCII string for an OSM id.

That are the design considerations:

  • The OSM id alone is not stable enough (as probably most agree); and it can represent many concepts (and that's by design in OSM).
  • The version no. of the object is needed which makes clear which tags are (or have been) referred to.
  • Coordinates are needed, because a change of the way and area geometries does not increment the version number.

Status of OSM id

One can use OSM id nevertheless (at own risk)! Many variants are known:

As is with OSM id (bigint) and a code for Node, Way, Relation e.g. in front (e.g. way/417258377). Currently many applications depend on plain osm_id, eventually preceeded by node,way,relation (or N/W/R), like theses web applications (given example of "Denner Hombrechtikon" https://www.openstreetmap.org/node/6313169265):

Another adoption of osm_id with enhanced type space (length) properties is to convert it to a single big integer: It's possible to encode the type (Node, Way, Relation) into the OSM id as a single integer (64 bit). (Source: Mapbox, see [1]). Example: "Schloss Kyburg" is a relation with id 1169711, so it becomes 11697114.

 for Nodes: osm_id = <node id> × 10  (eg. 123 → 1230), 
 for Ways: osm_id = (<way id> × 10) + 1  (eg. 123 → 1231), 
 for Relations: osm_id = (<relation id> × 10) + 4  (eg. 123 → 1234).

Recommendations

These is what we currently recommend, depending on the setting (see explanations below):

  1. Node-Way-Relation OSM id (at own risk).
  2. Wikidata QID with OSM backlink.
  3. Overpass Permanent ID with objekt-group-specific ID.
  4. OSM Permanent ID with geo URL

OSM Permanent ID with geo URL

A stable Permanent ID could have the following form using the 'geo' URI scheme (variable length to a maximum of currently 42 chars):

 'geo:'[+|-]<lon>[+|-]<lat>'?q='[node|way|relation]'/'<osm_id>#<osm_version>

where:

  • the form 'relation/1169711' is the same as e.g. Overpass JSON output produces as @id.
  • osm_id an unsigned big integer ("digits").
  • osm_version is an unsigned integer with a hash in front.
  • coordinates (lat/lon) are signed floats (always showing the +/- sign), with a maximum of 6 digits. In case of a line (linestring) or an area (multipolygon relation) geometries, the coordinates taken into account are the lat/lon minimum of the geometry.

Example: "Schloss Kyburg" (Castle Kyburg) has relation 1169711, version #5 at coordinates 47.4584, 8.74343 which becomes following OSM Permanent ID (osm_pid):

 osm_pid = geo:47.4584,8.74343?q=relation/1169711#5

OSM Permanent ID Service

In order to be really useful, a service should be implemented, which returns most recent object given a possibly old Permanent ID if an object has been changed; thus having another Permanent ID where any of it's parts may have changed (most probably just the version no.). Such a service must have access to the fully planet including the history and it must be reliable and responsive.

Alternatives

 See https://wiki.openstreetmap.org/wiki/Permanent_ID for a more official state of discussions. 

Wikidata QID with OSM backlink

If all objects in question are allowed to become a Wikidata (WD) object, add the Wikidata QID with key 'wikidata' to the OSM object. This one-way link from OSM to Wikidata then can be turned into a two way relationship using database techniques of JOINs. On the other hand you can add to a Wikidata object the coordinates (P625) and the OSM relation id (P402). Many mashups of OSM, Wikidata and Wikipedia use this solution, like the castle dossier (Burgen-Dossier) and others.

Example for Castle Kyburg: Q573643.

 Warning: Don't shoehorn all OSM objects to relations just because Wikidata only knows OSM relation id (and no node/way id)!

'geo' URI as OSM Permanent ID

For the use case to really permanently refer to an OSM object see also the URI Scheme "Uniform Resource Identifier for Geographic Locations " ('geo' URI).

For a promising implementation see Mangrove.reviews.

Example: Supermarket Denner Partner, Hombrechtikon, https://www.openstreetmap.org/node/6313169265

Overpass' Permanent ID

The Permanent_ID from Overpass is a solution where one expects to see the details (= "Link to Browse Object") and which relies purely on (non-geographic) tags: https://wiki.openstreetmap.org/wiki/Overpass_API/Permanent_ID

Example for Castle Kyburg: '[out:custom];rel[wikidata=Q573643];out;' => Q573643

Others

  • OpenLR (Location Referencing) - a free spec. by TomTom for linear geometries like streets [2].
  • The geographical object IDs from authorities like Ordnance Survey UK or Swisstopo CH.