query-17850ab47692aa68d293a533d5f4edf7

rq turtle/ttl

Nearest hospitals (to HTW Berlin) that provide emergency services SELECT ?hospital ?hospitalLabel ?emergency ?loc2 ?loc1 ?distKm WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". } wd:Q875138 wdt:P625 ?loc1. #setting HTW Berlin as 1st (current) location ?hospital wdt:P31 wd:Q16917; wdt:P131 wd:Q64; wdt:P6855 ?emergency; wdt:P625 ?loc2. #setting 2nd location for found hospital BIND(geof:distance(?loc1, ?loc2) AS ?distKm). #dist in kilometer } ORDER BY ASC(?distKm)

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#>
#Nearest hospitals (to HTW Berlin) that provide emergency services
SELECT ?hospital ?hospitalLabel ?emergency ?loc2 ?loc1 ?distKm WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". }
  wd:Q875138 wdt:P625 ?loc1. #setting HTW Berlin as 1st (current) location
  ?hospital wdt:P31 wd:Q16917;
    wdt:P131 wd:Q64;
    wdt:P6855 ?emergency;
    wdt:P625 ?loc2. #setting 2nd location for found hospital
    BIND(geof:distance(?loc1, ?loc2) AS ?distKm). #dist in kilometer
}
ORDER BY ASC(?distKm)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?distKm"):::projected v4("?emergency"):::projected v3("?hospital"):::projected v2("?loc1"):::projected v5("?loc2"):::projected c4(["#91;AUTO_LANGUAGE#93;,de"]):::literal c2(["bd:serviceParam"]):::iri c8(["wd:Q16917"]):::iri c10(["wd:Q64"]):::iri c5(["wd:Q875138"]):::iri subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end c5 --"wdt:P625"--> v2 v3 --"wdt:P31"--> c8 v3 --"wdt:P131"--> c10 v3 --"wdt:P6855"--> v4 v3 --"wdt:P625"--> v5 bind0[/"http://www.opengis.net/def/function/geosparql/distance(?loc1,?loc2)"/] v2 --o bind0 v5 --o bind0 bind0 --as--o v6