query-cca920f10b2e9dbfe488ea3bd9801aeb

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 ?place ?placeLabel (min(?dist) as ?distance)  where
{
 {
  SELECT ?item ?place ?dist
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)
  } }  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} group by ?place ?placeLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?dist"):::projected v7("?distance") 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 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end bind3[/"min(?dist)"/] v6 --o bind3 bind3 --as--o v7