query-02759c25e4489d62de949524b8b9a6ab

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX bd: <http://www.bigdata.com/rdf#>
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)
    || (
      geof:longitude(?location1) = geof:longitude($location2)
      && geof:latitude(?location1) < geof:latitude($location2)
    )
  ).

  # locations must be different
  FILTER (?distance > 0).

  # maximum distance
  FILTER (?distance < 100).

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?distance"):::projected v4("?fort"):::projected v2("?location1"):::projected v3("?location2"):::projected c4(["wd:Q1785071"]):::iri c7(["bd:serviceParam"]):::iri c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["?distance < '100^^xsd:integer'"]] f0 --> v5 f1[["?distance > '0^^xsd:integer'"]] f1 --> v5 f2[["(http://www.opengis.net/def/function/geosparql/longitude(?location1) < http://www.opengis.net/def/function/geosparql/longitude(?location2) || http://www.opengis.net/def/function/geosparql/longitude(?location1) = http://www.opengis.net/def/function/geosparql/longitude(?location2)http://www.opengis.net/def/function/geosparql/latitude(?location1) < http://www.opengis.net/def/function/geosparql/latitude(?location2))"]] f2 --> v2 f2 --> v3 v4 --"wdt:P31"--> c4 v4 --"wdt:P625"--> v2 v4 --"wdt:P625"--> v3 bind3[/"http://www.opengis.net/def/function/geosparql/distance(?location1,?location2)"/] v2 --o bind3 v3 --o bind3 bind3 --as--o v5 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end