Permanent ID for OSM: Unterschied zwischen den Versionen

Aus Geoinformation HSR
Wechseln zu: Navigation, Suche
(Overpass' Permanent ID)
(Overpass API Permanent ID)
Zeile 81: Zeile 81:
  
 
Castle "Kyburg":
 
Castle "Kyburg":
* Coordinates:
+
* Coordinates:  
* Properties: Wikidata item no. Q573643  
+
* Properties: Wikidata item no. Q573643 (note the minimal output without meta data in this Overpass query).
* Overpass Query: '[out:custom];rel[wikidata=Q573643];out;'
+
* Overpass Query: <code>[out:custom];rel[wikidata=Q573643];out;</code>
 
* Overpass Permanent ID with JSON output (API): https://overpass-api.de/api/interpreter?data={{urlencode:[out:json];rel[wikidata=Q573643];out;}}
 
* Overpass Permanent ID with JSON output (API): https://overpass-api.de/api/interpreter?data={{urlencode:[out:json];rel[wikidata=Q573643];out;}}
 
* Overpass Permanent ID with browse OSM.org: https://overpass-api.de/api/interpreter?data={{urlencode:[out:custom];rel[wikidata=Q573643];out;}}
 
* Overpass Permanent ID with browse OSM.org: https://overpass-api.de/api/interpreter?data={{urlencode:[out:custom];rel[wikidata=Q573643];out;}}
Zeile 91: Zeile 91:
 
* Properties: type 'historic'
 
* Properties: type 'historic'
 
* OSM.org: https://www.openstreetmap.org/way/289329862#map=19/47.30888/8.86706
 
* OSM.org: https://www.openstreetmap.org/way/289329862#map=19/47.30888/8.86706
* Overpass Query: [out:json];nwr(around:5,47.30888,8.86706)[historic];out meta center;
+
* Overpass Query: <code>[out:json];nwr(around:5,47.30888,8.86706)[historic];out meta center;</code>
 
* Overpass Permanent ID with JSON output (API): https://overpass.osm.ch/api/interpreter?data=%5Bout%3Ajson%5D%3Bnwr%28around%3A5%2C47.30888%2C8.86706%29%5Bhistoric%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with JSON output (API): https://overpass.osm.ch/api/interpreter?data=%5Bout%3Ajson%5D%3Bnwr%28around%3A5%2C47.30888%2C8.86706%29%5Bhistoric%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with browse OSM.org: https://overpass.osm.ch/api/interpreter?data=%5Bout%3Acustom%5D%3Bnwr%28around%3A5%2C47.30888%2C8.86706%29%5Bhistoric%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with browse OSM.org: https://overpass.osm.ch/api/interpreter?data=%5Bout%3Acustom%5D%3Bnwr%28around%3A5%2C47.30888%2C8.86706%29%5Bhistoric%5D%3Bout%20meta%20center%3B
Zeile 99: Zeile 99:
 
* Properties amenity=restaurant (at ground level).  
 
* Properties amenity=restaurant (at ground level).  
 
* OSM.org: https://www.openstreetmap.org/node/1706090806
 
* OSM.org: https://www.openstreetmap.org/node/1706090806
* Overpass Query: [out:json];nwr(around:5,47.2229817,8.8163386)[amenity="restaurant"];out meta center;
+
* Overpass Query: <code>[out:json];nwr(around:5,47.2229817,8.8163386)[amenity="restaurant"];out meta center;</code>
 
* Overpass Permanent ID with JSON output (API):  https://overpass.osm.ch/api/interpreter?data=%5Bout%3Ajson%5D%3Bnwr%28around%3A5%2C47.2229817%2C8.8163386%29%5Bamenity%3D%22restaurant%22%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with JSON output (API):  https://overpass.osm.ch/api/interpreter?data=%5Bout%3Ajson%5D%3Bnwr%28around%3A5%2C47.2229817%2C8.8163386%29%5Bamenity%3D%22restaurant%22%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with browse OSM.org:  https://overpass.osm.ch/api/interpreter?data=%5Bout%3Acustom%5D%3Bnwr%28around%3A5%2C47.2229817%2C8.8163386%29%5Bamenity%3D%22restaurant%22%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with browse OSM.org:  https://overpass.osm.ch/api/interpreter?data=%5Bout%3Acustom%5D%3Bnwr%28around%3A5%2C47.2229817%2C8.8163386%29%5Bamenity%3D%22restaurant%22%5D%3Bout%20meta%20center%3B
Zeile 107: Zeile 107:
 
* Properties: room="auditorium" (at level 1, note that's at same coords as Mensa below).
 
* Properties: room="auditorium" (at level 1, note that's at same coords as Mensa below).
 
* OSM.org: https://www.openstreetmap.org/way/903296474
 
* OSM.org: https://www.openstreetmap.org/way/903296474
* Overpass Query: [out:json];nwr(around:10,47.2229817,8.8163386)[room="auditorium"];out meta center;
+
* Overpass Query: <code>[out:json];nwr(around:10,47.2229817,8.8163386)[room="auditorium"];out meta center;</code>
 
* Overpass Permanent ID with JSON output (API): https://overpass.osm.ch/api/interpreter?data=%5Bout%3Ajson%5D%3Bnwr%28around%3A10%2C47.2229817%2C8.8163386%29%5Broom%3D%22auditorium%22%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with JSON output (API): https://overpass.osm.ch/api/interpreter?data=%5Bout%3Ajson%5D%3Bnwr%28around%3A10%2C47.2229817%2C8.8163386%29%5Broom%3D%22auditorium%22%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with browse OSM.org: https://overpass.osm.ch/api/interpreter?data=%5Bout%3Acustom%5D%3Bnwr%28around%3A9%2C47.2229817%2C8.8163386%29%5Broom%3D%22auditorium%22%5D%3Bout%20meta%20center%3B  
 
* Overpass Permanent ID with browse OSM.org: https://overpass.osm.ch/api/interpreter?data=%5Bout%3Acustom%5D%3Bnwr%28around%3A9%2C47.2229817%2C8.8163386%29%5Broom%3D%22auditorium%22%5D%3Bout%20meta%20center%3B  
Zeile 116: Zeile 116:
 
* Properties: name~"Gebäude 4" (note that's still at same coords this time referring to an enclosing feature; around was increased again due to the larger object extension).
 
* Properties: name~"Gebäude 4" (note that's still at same coords this time referring to an enclosing feature; around was increased again due to the larger object extension).
 
* OSM.org: https://www.openstreetmap.org/way/34754484
 
* OSM.org: https://www.openstreetmap.org/way/34754484
* Overpass Query: [out:json];nwr(around:15,47.2229817,8.8163386)[name~"Gebäude 4"];out meta center;
+
* Overpass Query: <code>[out:json];nwr(around:15,47.2229817,8.8163386)[name~"Gebäude 4"];out meta center;</code>
 
* Overpass Permanent ID with JSON output (API): https://overpass.osm.ch/api/interpreter?data=%5Bout%3Ajson%5D%3Bnwr%28around%3A15%2C47.2229817%2C8.8163386%29%5Bname~%22Geb%C3%A4ude%204%22%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with JSON output (API): https://overpass.osm.ch/api/interpreter?data=%5Bout%3Ajson%5D%3Bnwr%28around%3A15%2C47.2229817%2C8.8163386%29%5Bname~%22Geb%C3%A4ude%204%22%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with browse OSM.org: https://overpass.osm.ch/api/interpreter?data=%5Bout%3Acustom%5D%3Bnwr%28around%3A15%2C47.2229817%2C8.8163386%29%5Bname~%22Geb%C3%A4ude%204%22%5D%3Bout%20meta%20center%3B
 
* Overpass Permanent ID with browse OSM.org: https://overpass.osm.ch/api/interpreter?data=%5Bout%3Acustom%5D%3Bnwr%28around%3A15%2C47.2229817%2C8.8163386%29%5Bname~%22Geb%C3%A4ude%204%22%5D%3Bout%20meta%20center%3B

Version vom 21. Februar 2021, 22:46 Uhr

 This is an unofficial proposal for a "OSM permanent ID" (osm_pid) for OpenStreetMap (OSM). 
 
 See https://wiki.openstreetmap.org/wiki/Permanent_ID for an official place for discussions. 

Status of OSM id

One can use OSM id nevertheless (at own risk)! Many variants are known in order to get a single unique identifier value. Some are of type string and others calculate a value of type big integer.

String type based - using OSM ID number plus 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):

Integer type based - using shifting on the three elements of OSM ID numbers:

  • "Overpass": Overpass uses an own schema to calculate an id of integer-type : https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#By_area_.28area.29
  • "Mapbox Streets V7": 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 older Version V7 of Mapbox Streets [1]). Example: "Schloss Kyburg" is a relation with id 1169711, so it becomes 11697114. See also OpenMaptiles
 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).

I, Stefan, prefer W417258377 for a string typed id, and Mapbox Streets V7 for number based.

Recommendations

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

  1. OSM id with Node-Way-Relation code (at own risk). Example 'relation/1169711'.
  2. Wikidata QID with OSM backlink. Example 'Q573643'.
  3. Overpass Permanent ID with objekt-group-specific ID. Example '[out:custom];rel[wikidata=Q573643];out;'
  4. OSM Permanent ID with geo URI. Example 'geo:47.45835,8.74375?q=relation/1169711#5'.

OSM Permanent ID with geo URI

 This proposal is now also on the official OSM Wiki page: https://wiki.openstreetmap.org/wiki/Permanent_ID#OSM_Permanent_ID_with_geo_URI

The goals and requirements of this new proposal are to get a compact human readable string as an OSM id.

  • The OSM id alone is not stable enough (as stated above) and it can represent many concepts (and that's by design in OSM).
  • The version no. of the OSM object is needed which makes clear which tags are (or have been) referred to.
  • Coordinates are needed also, because a change of the way and area geometries does not increment the version number. Coordinates plus parameters fit well to the international 'geo' URI scheme.

Thus, a stable OSM Permanent ID could have the following form using the 'geo' URI scheme:

 '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 no more than 6 digits if possible. In case of a line (linestring) or an area (multipolygon relation) geometry, the coordinates either are taken from any node of the geometry, or calculated e.g. from the center of the geometry.

The OSM Permanent ID is mainly numeric plus some fixed tokens and it has a variable length of a maximum of 42 chars.

Example: "Schloss Kyburg" (Castle Kyburg) has relation 1169711, version #5 at coordinates 47.45835, 8.74375 - and becomes following OSM Permanent ID (osm_pid):

 geo:47.45835,8.74375?q=relation/1169711#5

There's an implementation by Mangrove.reviews with some different parameters q=<name> and u=30 (u = 'uncertainty' in meters). Example: 'geo:47.45835,8.74375?q=Kyburg&u=30' => [2]

 Note: The geo URI looks like a web link (URL). Unfortunately almost no browser supports this URI 'out of the box', only Android systems.

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.

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)!

Overpass API 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 .

Note that the user has to choose at least coordinates and an "around" parameter in Meters plus an identifying property (i.e. a key or a tag). Without this property e.g. OSM objects can't be disambiguated which are on different levels, like shops or rooms (see below).

Examples

Castle "Kyburg":

Castle "Ruine Bernegg":

Restaurant "Mensa OST RJ":

Room "Auditorium OST RJ":

Building "OST RJ Gebäude 4":

Others

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