query-533f31d69a606909013def7edf1e6a2c

rq turtle/ttl

Filter by inequality: nearly antipodal capitals

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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 DISTINCT ?country1Label ?country2Label ?capital1Label ?capital2Label ?distance WHERE {
  ?country1 wdt:P31 wd:Q6256 ;
            wdt:P36 ?capital1 .

  ?country2 wdt:P31 wd:Q6256 ;
            wdt:P36 ?capital2 .

  ?capital1 wdt:P625 ?coords1 .
  ?capital2 wdt:P625 ?coords2 .

  BIND(ROUND(geof:distance(?coords1, ?coords2)) AS ?distance) .
  FILTER (?distance>19000)

  FILTER(xsd:string(?capital1) < xsd:string(?capital2)) 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
ORDER BY DESC(?distance)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?capital1") v3("?capital2") v6("?coords1") v7("?coords2") v4("?country1") v5("?country2") v8("?distance"):::projected c7(["bd:serviceParam"]):::iri c9(["en"]):::literal c3(["wd:Q6256"]):::iri f0[["http://www.w3.org/2001/XMLSchema#string(?capital1) < http://www.w3.org/2001/XMLSchema#string(?capital2)"]] f0 --> v2 f0 --> v3 f1[["?distance > '19000^^xsd:integer'"]] f1 --> v8 v4 --"wdt:P31"--> c3 v4 --"wdt:P36"--> v2 v5 --"wdt:P31"--> c3 v5 --"wdt:P36"--> v3 v2 --"wdt:P625"--> v6 v3 --"wdt:P625"--> v7 bind2[/"numeric-round(http://www.opengis.net/def/function/geosparql/distance(?coords1,?coords2))"/] v6 --o bind2 v7 --o bind2 bind2 --as--o v8 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end