query-5ea2b548e3794c26521599e7e6341a67

rq turtle/ttl

TagishsimonElya

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 ?place ?placeLabel ?distance WHERE
{
   {
  SELECT ?place (MIN(?dist) AS ?distance)
WHERE
{

  VALUES ?sea_thing {
    wd:Q44782 #port
    wd:Q283202 #harbour
  }
  ?item wdt:P131* wd:Q22. 
  ?item wdt:P31 ?sea_thing.
  ?item wdt:P625 ?item_coord.

  ?place wdt:P131* wd:Q22. 
  ?place wdt:P31 wd:Q532.
  ?place wdt:P625 ?place_coord .  

  BIND(geof:distance(?item_coord, ?place_coord) as ?dist)
}
GROUP BY ?place
}  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; v6("?dist") v7("?distance"):::projected v2("?item") v3("?item_coord") v4("?place"):::projected v5("?place_coord") v1("?sea_thing") c5(["wd:Q532"]):::iri c7(["bd:serviceParam"]):::iri c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal c2(["wd:Q22"]):::iri bind0[/VALUES ?sea_thing/] bind0-->v1 bind00(["wd:Q44782"]) bind00 --> bind0 bind01(["wd:Q283202"]) bind01 --> bind0 v2 --"wdt:P131"--> c2 v2 --"wdt:P31"--> v1 v2 --"wdt:P625"--> v3 v4 --"wdt:P131"--> c2 v4 --"wdt:P31"--> c5 v4 --"wdt:P625"--> v5 bind1[/"http://www.opengis.net/def/function/geosparql/distance(?item_coord,?place_coord)"/] v3 --o bind1 v5 --o bind1 bind1 --as--o v6 bind3[/"min(?dist)"/] v6 --o bind3 bind3 --as--o v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end