query-03058937c5ae54a512e9a5aa8ed1e183

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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT DISTINCT ?river ?item ?lat ?long ?coord2 ?dist WHERE { 
    {
      VALUES ?river {wd:Q24639723} .

      ?river p:P403 ?stat. 
      ?river wdt:P131/wdt:P131 wd:Q22 .
      ?stat pq:P625 ?coord .                            # get the coords for the main river

      ?stat2 ps:P403 ?river.
      ?item p:P403 ?stat2. 
      ?stat2 pqv:P625/wikibase:geoLatitude ?lat. 
      ?stat2 pqv:P625/wikibase:geoLongitude ?long.
      ?stat2 pq:P625 ?coord2 .                          # get coords for all tributary rivers
      BIND(geof:distance(?coord, ?coord2) as ?dist)       # distance between tributary mouth and main river mouth
    }
    UNION
    {
      VALUES ( ?river ?item ?dist ) { ( wd:Q24639723 wd:Q24639723 0.0 ) }
      ?river p:P625 ?stat.
      ?stat ps:P625 ?coord2.
      ?stat psv:P625/wikibase:geoLatitude ?lat. 
      ?stat psv:P625/wikibase:geoLongitude ?long.
    }
  }

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?coord") v8("?coord2"):::projected v10("?dist"):::projected v10("?item"):::projected v6("?lat"):::projected v7("?long"):::projected v10("?river"):::projected v2("?stat") v4("?stat2") a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) c3(["wd:Q22"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; bind0[/VALUES ?dist ?item ?river/] bind0-->v10 bind0-->v10 bind0-->v10 bind00(["wd:Q24639723"]) bind00 --> bind0 bind01(["wd:Q24639723"]) bind01 --> bind0 bind02(["0.0^^xsd:decimal"]) bind02 --> bind0 v10 --"p:P625"--> v2 v2 --"p:statement/P625"--> v8 v2 --"p:statement/value/P625"--> a4 a4 --"wikibase:geoLatitude"--> v6 v2 --"p:statement/value/P625"--> a5 a5 --"wikibase:geoLongitude"--> v7 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; bind1[/VALUES ?river/] bind1-->v10 bind10(["wd:Q24639723"]) bind10 --> bind1 v10 --"p:P403"--> v2 v10 --"p:direct/P131"--> a1 a1 --"p:direct/P131"--> c3 v2 --"p:qualifier/P625"--> v3 v4 --"p:statement/P403"--> v10 v10 --"p:P403"--> v4 v4 --"p:qualifier/value/P625"--> a2 a2 --"wikibase:geoLatitude"--> v6 v4 --"p:qualifier/value/P625"--> a3 a3 --"wikibase:geoLongitude"--> v7 v4 --"p:qualifier/P625"--> v8 bind2[/"http://www.opengis.net/def/function/geosparql/distance(?coord,?coord2)"/] v3 --o bind2 v8 --o bind2 bind2 --as--o v10 end union0r <== or ==> union0l end