Permanent ID/Proposal-QID
All important Map Feature in the OSM can be assigned to a Wikidata Item (by key:wikidata), that is a unique and "eternal" identifier.
It is a positive integer number, prefixed by the letter "Q". For example the country Brazil is identified by the "QID" Q155, so Q155 is the unique Wikidata identifier of the country Brazil.
In July 2018 there are:
- ~1,125,000 OSM elements with a wikidata key.
(there are many elements representing same feature — e.g. a relation and a node representing the same building). - ~63,000 OSM features (represented by relations) with Wikidata reciprocal use.
Each feature having a permanent Wikidata ID, and a statement OSM relation ID (P402) pointing to the OSM online map.
Proposal to redirect Wikidata identifier
Redirect Wikidata QIDs by http://osm.org/Q$1
to the respective geometry. Examples:
- Relation. The Wikidata item that represents the concept of the country Brazil (Q155), on OSM is a relation,
http://osm.org/Q155
will redirect to https://www.openstreetmap.org/relation/etc
- Way. The Wikidata item that represents the concept of the Fraternity Bridge (Q2679759), on OSM is a way,
http://osm.org/Q2679759
will redirect to https://www.openstreetmap.org/way/etc
- Node. Wikidata item of the Number zero survey marker of the city of São Paulo, (Q10325364), on OSM is a node,
http://osm.org/Q10325364
will redirect to https://www.openstreetmap.org/node/etc
To use the OSM.ORG is also subject of discussion, please see Talk:Osm.org.
Proof of concept and basic implementation
Using the above examples:
The redirect minimal algorithm depends on a simple lookup table of 64-bit integers, a lightweight database and conversion function:
CREATE TABLE wd_osm_minimal (
wd_id bigint NOT NULL PRIMARY KEY, -- the Wikidata QID
osm_type char(1) NOT NULL, -- the element-type (n=node,w=way,r=relation,e=err)
osm_id bigint NOT NULL, -- the OSM uniqueID at osm_type namespace
UNIQUE(osm_type,osm_id)
);
CREATE FUNCTION wdosm.osm_url(p_osm_type char, p_id bigint) RETURNS text AS $f$
-- includes an error handler to help user to fix a wd_id attribution error
SELECT concat(
CASE WHEN $1='e' THEN 'http://list.osm.org/'
ELSE 'https://www.openstreetmap.org/' END
,CASE WHEN $1='w' THEN 'way'
WHEN $1='r' THEN 'relation'
WHEN $1='n' THEN 'node'
ELSE 'error' END
,'/',
p_id::text
)
$f$ language SQL IMMUTABLE;
At HTTP server, e.g. Nginx, the rewrite engine is based on the regular expression "^[qQ](\d+)$"
, that reacts only to Wikidata QIDs, preserving other alternative uses to the osm.org domain.