4

I'm building an application which will display maps via OSM and I'll need to be able to reference a couple of countries and cities from within my app.

Assume these are:

Can I assume that those types + ids (e.g Italy is a relation with id 365331 and Athens is node with id 441183) will never change in OSM?

Or should I base my application on long/lat for those places which will, obviously, never change?

7

(Most) IDs in OSM can and will change. They are not stable.

IDs in OSM change whenever someone deletes (and possibly re-creates) an element, or re-uses an existing element for a new purpose.

For elements that are reasonably important (like those from your question) it is quite unlikely to get deleted. Such changesets will usually get reverted. Nevertheless you should not depend on individual IDs since it is just a matter of time until they break, either temporarily or constantly.

Possible solutions:

  • Determine IDs once (automatically or manually), store latitude, longitude and relevant tags instead of the IDs.
  • Determine IDs automatically each time you need them. For example via Overpass API queries by searching for the name and admin_level keys.
  • 1
    Determining the ID via Overpass API each time you need it seems like a bad idea for an app in general, as it might create too much load on the public instances. If you need stable ids and boundaries, you should probably set up your own server and use it as a cache for your app. – mmd Apr 17 '18 at 16:28
  • Yes, depends on the specific use case. Alternatively use some approach in between, e.g. update your IDs once in a week. – scai Apr 17 '18 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.