query-51d7af3cd2eb263002d440c25e4b98ee

rq turtle/ttl

Forts with 2 coordinates mentioned, sorted by distance apart

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?fort ?fortLabel ?location1 ?location2 ?distance
WHERE 
{
  ?fort wdt:P31 wd:Q1785071.
  ?fort wdt:P625 ?location1.
  ?fort wdt:P625 ?location2.
  BIND(geof:distance(?location1, ?location2) as ?distance).

  # deduplicate (by picking location1 to be either east or exactly north of location2)
  FILTER (
    geof:longitude(?location1) < geof:longitude($location2)|

Query found at