If I want to store an identifier to a particular location in OSM, what's the best way to do this please? For example: If I want to store the link to Hyde Park, I can use this: Way: Hyde Park (372975520) https://www.openstreetmap.org/way/372975520 Whereas if I want to store a link to Wimbledon Common, it's listed as this: Relation: Wimbledon Common (4285108) https://www.openstreetmap.org/relation/4285108 Note that one is a Way and the other is a Relation. Are these numbers still useful as UIDs? Or should I be storing the ID and the type (Way/Relation etc)? Any guidance appreciated! asked 02 Jan '20, 11:24 ab76555 |
Since IDs can change, there is no definite solution. There are some workarounds (e.g. using Wikidata) listed on the wiki page Permanent ID answered 02 Jan '20, 13:44 escada |
For completeness, if you just want to store a link to a location, you can store what's in the browser URL (for Hyde Park at zoom 15 that's https://www.openstreetmap.org/#map=15/51.5070/-0.1729 ). That's not linking to a particular object in OSM but is linking to a location.
Thanks for the quick reply! What if I do want access to OSM object too? For example, if I've got a database that stores locations alongside ratings (which I'm accessing through my API), and I occasionally want to access the OSM object (for example, I might query my_location_id/osm_object_coordinates).
escada's answer covers the aspect of permanent linking. Regarding your question about the way and relation IDs, each object type has its own numbering. That is, there's a node #1, way #1, and relation #1, all representing different things. So, to identify an object using its ID, you'd also need to record its object type.
Brilliant - thanks all for your help. That's great to know about the node/way numbering!