I’d like to use Overpass Turbo to check closed boundary relations. This query looks for boundary=barony in a small area, and finds three. One of those is just an area (not a complicated multipolygon) and appears valid to Josm’s validator. For comparison a neighbour has an obvious gap in it.
I’d have expected a query like this (with (if: is_closed() == 1 )) to return the complete one and not the other - that works for closed linear ways, but it does not work here.
I’d have expected a query like this https://overpass-turbo.eu/s/22x4
(with |(if: is_closed() == 1 )|) to return the complete one and not the
other - that works for closed linear ways, but it does not work here.
This is a little bit tricky. Closedness is for relations a property of
the referred ways and not of the relation itself. I.e. the same version
of a relation can be closed and not closed if already only the
underlying ways change.
I suggest the following approach:
this checks whether the totality of ways have nodes that are connected
to only one or three or more way segments. Those relations have
definitely a problem (which might be fixed by an edit to only member
ways, or new members), and relations where all used nodes are part of
exactly two segments have no problem of being not closed (could still
self-intersect).
In case you’re open to using a different tool, here’s a very simple SPARQL query for QLever that finds broken boundary relations:
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX osm2rdf: <https://osm2rdf.cs.uni-freiburg.de/rdf#>
PREFIX osmkey: <https://www.openstreetmap.org/wiki/Key:>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX osm: <https://www.openstreetmap.org/>
SELECT * WHERE {
?boundary rdf:type osm:relation .
?boundary osmkey:type "boundary" .
MINUS {
?boundary osm2rdf:area [] .
}
# Or whatever else you want to know about the broken boundaries.
OPTIONAL {
?boundary osmkey:name ?name .
}
}
A similar query for broken multipolygons is available on the wiki. This all works because osm2rdf automatically postprocesses each multipolygon or boundary relation in OSM to add its geometry, area, and perimeter. If a given relation’s geometry doesn’t result in a closed (multi)polygon, then no osm2rdf:area triple is created.
The catch is that QLever’s osm2rdf only keeps up with weekly planet dumps, so it’s well behind the Overpass API, Postpass, and Sophox.