External database with additional information for nodes and ways

Hi there,

I am thinking about ways to add custom information to certain nodes and ways, that are not meant for the OSM model. For example detailed descriptions and user reviews.

I wonder how I could create a relation between OSM data and my data. I see that any node/way/relation has an ID, where a node can have the same ID as a way. I read in the wiki that IDs of deleted nodes must not be reassigned (unless the exact same node was deleted by accident or so). But then I read somewhere here in the forums that I cannot be certain that a node’s ID will not change over time?

Stadtpirat

The main reason that IDs may change is that common editing operations involve creating new objects - for example, if someone wants to draw a park as an area that was previously only marked with a node carrying the park’s name, the park’s ID will change to that area’s ID. Or if someone wants to make a hole into a building that was mapped as a closed way before, they have to create a multipolygon relation, and that relation’s ID will become the ID of the building as a whole.

So while an ID is usually not used for something completely different in the future (though there are no technical protections against that, it’s just considered bad style and generally hard to do accidentally), the same real-world feature may well get a different ID.

Linking external data to OSM is therefore not really solved. However, depending on what kind of objects you want to link, some solutions may be feasible. For example, let’s say you want to link to restaurants. You might then be able to do the following:

  • when the restaurant is first added to your DB, store not only the ID, but also the location (and maybe other identifying information)
  • automatically check every now and then whether the ID is still alive and is still associated with a restaurant tag
  • only if that is no longer the case, query Overpass API for restaurants with the previously stored location and other information. If there is a result, then use that as the new ID for the restaurant.

I see. That’s a lot of work. But obviously the only solution.