query-6fad49df88454c68f286e3a0b576ec19

rq turtle/ttl

Bathing waters in Sweden connected to water showing distanceA line is shown from the coordinate of the bathing water to the coordinate of the connected water is unique id of Swedish water(P761)Lake ID (Sweden) (P206)located in or next to body of water

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 p: <http://www.wikidata.org/prop/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title: Swedish Bathing waters with line to connected water
#defaultView:Map{"hide":["?bathcoord","?lakecoord","?line","?str","?layer"]}
SELECT ?str ?bathingwater ?bathingwaterLabel ?bathcoord ?lake ?lakeLabel ?lakecoord ?dist ?line ?SJOID ?layer ?EionetBathingWaterIDentifier ?Hav ?VISS WHERE {
  ?bathingwater wdt:P6104 wd:Q106774536.
   ?bathingwater  wdt:P625 ?xx.
   ?bathingwater  p:P625 [ a wikibase:BestRank ;
           psv:P625 [
             wikibase:geoLatitude ?bathcoordlat ;
             wikibase:geoLongitude ?bathcoordlon ;
             wikibase:geoGlobe ?globe ;
           ] ;
           ps:P625 ?bathcoord
          ]
  OPTIONAL { ?bathingwater wdt:P9616 ?EionetBathingWaterIDentifier. }
  {
    ?bathingwater wdt:P206 ?lake.
   ?lake  wdt:P625 ?rr.
       ?lake  p:P625 [a wikibase:BestRank ;
           psv:P625 [
             wikibase:geoLatitude ?lat ;
             wikibase:geoLongitude ?long ;
             wikibase:geoGlobe ?globe2 ;
           ] ;
           ps:P625 ?lakecoord
          ]
    OPTIONAL { ?lake wdt:P761 ?SJOID. }
  }
   BIND(geof:distance(?bathcoord, ?lakecoord) as ?dist) . 
  #filter (?dist >= 3)
  BIND (floor(?dist/10)*10 as ?layer) 
  BIND(CONCAT('LINESTRING (', STR(?bathcoordlon), ' ', STR(?bathcoordlat), ',', STR(?long), ' ', STR(?lat), ')') AS ?str) .
  BIND(STRDT(?str, geo:wktLiteral) AS ?line) 
  BIND(URI(CONCAT("https://badplatsen.havochvatten.se/badplatsen/karta/#/bath/",?EionetBathingWaterIDentifier)) AS  ?Hav)
  BIND(URI(CONCAT("https://viss.lansstyrelsen.se/Waters.aspx?waterEUID=SE",?SJOID)) AS ?VISS)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,sv". }
}
ORDER BY DESC(?dist)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?EionetBathingWaterIDentifier"):::projected v19("?Hav"):::projected v15("?SJOID"):::projected v20("?VISS"):::projected v7("?bathcoord"):::projected v4("?bathcoordlat") v5("?bathcoordlon") v2("?bathingwater"):::projected v16("?dist"):::projected v6("?globe") v13("?globe2") v9("?lake"):::projected v14("?lakecoord"):::projected v11("?lat") v16("?layer"):::projected v18("?line"):::projected v12("?long") v10("?rr") v17("?str"):::projected v3("?xx") a1((" ")) a2((" ")) a3((" ")) a4((" ")) c18(["en,sv"]):::literal c5(["wikibase:BestRank"]):::iri c2(["wd:Q106774536"]):::iri c16(["bd:serviceParam"]):::iri v2 --"p:direct/P6104"--> c2 v2 --"p:direct/P625"--> v3 a1 --"a"--> c5 a2 --"wikibase:geoLatitude"--> v4 a2 --"wikibase:geoLongitude"--> v5 a2 --"wikibase:geoGlobe"--> v6 a1 --"p:statement/value/P625"--> a2 a1 --"p:statement/P625"--> v7 v2 --"p:P625"--> a1 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P9616".-> v8 end v2 --"p:direct/P206"--> v9 v9 --"p:direct/P625"--> v10 a3 --"a"--> c5 a4 --"wikibase:geoLatitude"--> v11 a4 --"wikibase:geoLongitude"--> v12 a4 --"wikibase:geoGlobe"--> v13 a3 --"p:statement/value/P625"--> a4 a3 --"p:statement/P625"--> v14 v9 --"p:P625"--> a3 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v9 -."p:direct/P761".-> v15 end bind0[/"http://www.opengis.net/def/function/geosparql/distance(?bathcoord,?lakecoord)"/] v7 --o bind0 v14 --o bind0 bind0 --as--o v16 bind1[/"numeric-floor(?dist / '10^^xsd:integer') * '10^^xsd:integer'"/] v16 --o bind1 bind1 --as--o v16 bind2[/"concat('LINESTRING (',str(?bathcoordlon),' ',str(?bathcoordlat),',',str(?long),' ',str(?lat),')')"/] v5 --o bind2 v4 --o bind2 v12 --o bind2 v11 --o bind2 bind2 --as--o v17 bind3[/"STRDT(?str,'geo:wktLiteral')"/] v17 --o bind3 bind3 --as--o v18 bind4[/"concat('https://badplatsen.havochvatten.se/badplatsen/karta/#/bath/',?EionetBathingWaterIDentifier)"/] v8 --o bind4 bind4 --as--o v19 bind5[/"concat('https://viss.lansstyrelsen.se/Waters.aspx?waterEUID=SE',?SJOID)"/] v15 --o bind5 bind5 --as--o v20 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c16 --"wikibase:language"--> c18 end