This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Get polygon’s osm_id from relation’s id

0

Hello,

I'm going to use Photon as a search engine. In a result, Photon give the id of the node / way / relation.

How can I get the associated point / roads / polygon in my OSM DB (I don't have a Nominatim DB)? Is it always -1*<id>? Am I sure to get a result?

Thanks in advance

asked 10 Jul '19, 12:41

Tim%20Autin's gravatar image

Tim Autin
16234
accept rate: 0%


One Answer:

0
  • If Photon gives you a node, it will either be in planet_osm_point with its ID, or not present at all.
  • If Photon gives you a way, it will either be in planet_osm_line with its ID, or in planet_osm_polygon with its ID, nor not present at all.
  • If Photon gives you a relation, it will either be in planet_osm_line with -ID, or in planet_osm_polygon with -ID, or not present at all.

answered 10 Jul '19, 12:44

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thank you very much for the very clear answer! The links between relations/line, relations/polygons, way/line & node/point are still a bit obscure to me. If a relation is updated/deleted/added, does the polygon (or line) also get updated/deleted/added?

(10 Jul '19, 12:49) Tim Autin

If you do process updates with your database (osm2pgsql -a), then yes, the polygon or line will get updated when the relation changes.

(10 Jul '19, 15:13) Frederik Ramm ♦

Source code available on GitHub .