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

Overpass turbo query for castles without duplicated nodes

0

Hi,

I want to build a query that returns for a given bbox:

  • List of POIs (one single node with coordinates) for all castles (historic=castle)
  • Some castles are mapped multiple times, for example: castle Trifels (Germany), so these rules should be applied:
  • If a single waypoint for historic=castle exists, this should be choosen
  • If not waypoint exists, the center of a way or relation should be used
  • Multiple mappings should be detected by a radius, as sometimes names are mapped different and thus a name can not be used as unique identifier.

In case of Trifels, there exists a way and a relation, both named different. But there is no single waypoint (node) for the castle.

Here is my code so far: https://overpass-turbo.eu/s/13Hp

[out:json];
// Find all castles, for testing 
nwr
  [historic=castle][name~".*Trifels"]
  ({{bbox}});
map_to_area -> .a;

foreach.a->.elem(
  // find areas already in .final near the curreent element
  area.final(around.elem:200) -> .deb;
  // get the nodes in this area, if any
  node(area.deb) -> .deb2;

  // if no nodes are in deb2, this is not a duplicate, so we can add it to .final
  if(.deb2.count(nodes) == 0) {
    (.elem; .final;) -> .final;
  }
);

.final out center; // .final contains areas, so we need center to get a single waypoint

But this returns both areas. It seems that someting is going wrong with the count. And this code is not complete, as it as no weighting for nodes vs. ways vs. realations. It's just first come, first serve.

Can someone help me to understand how to build such a query?

asked 16 Feb '21, 08:04

cytrinox's gravatar image

cytrinox
11112
accept rate: 0%

Source code available on GitHub .