query-e6c70447b9fbd49015bb9e6013286bf1
TweetsFactsAndQueriesdefaultView:Map(Q294297)public bookcase (Q28564)public library ?layer(P625)coordinate location
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"layer": ["?libraryLabel"], "hide" : ["?location1","?location2"]}
PREFIX geof: <http://www.opengis.net/def/geosparql/function/>
SELECT ?bookcase ?bookcaseLabel ?location1 ?location2 ?library ?libraryLabel ?distance
WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?Type rdfs:label ?layer. ?bookcase rdfs:label ?bookcaseLabel. ?library rdfs:label ?libraryLabel}
{
SELECT ?bookcase ?location1 ?library ?location2 ?distance ?layer WHERE {
{
SELECT ?bookcase ?location1 (MIN(?distance) AS ?minDistance) ?layer WHERE {
?bookcase wdt:P31 wd:Q294297;
wdt:P625 ?location1;
wdt:P17 wd:Q40.
?library wdt:P31 wd:Q28564;
wdt:P625 ?location2;
wdt:P17 wd:Q40.
BIND(geof:distance(?location1, ?location2) AS ?distance)
}
GROUP BY ?bookcase ?location1 ?layer
}
?library wdt:P31 wd:Q28564;
wdt:P625 ?location2;
wdt:P17 wd:Q40.
BIND(geof:distance(?location1, ?location2) AS ?distance)
FILTER(?distance = ?minDistance)
}
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?Type")
v3("?bookcase"):::projected
v4("?bookcaseLabel"):::projected
v11("?distance"):::projected
v2("?layer")
v5("?library"):::projected
v6("?libraryLabel"):::projected
v9("?location1"):::projected
v10("?location2"):::projected
v11("?minDistance")
c2(["bd:serviceParam"]):::iri
c11(["wd:Q28564"]):::iri
c10(["wd:Q40"]):::iri
c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c7(["wd:Q294297"]):::iri
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
v1 --"rdfs:label"--> v2
v3 --"rdfs:label"--> v4
v5 --"rdfs:label"--> v6
end
f0[["?distance = ?minDistance"]]
f0 --> v11
f0 --> v11
v3 --"wdt:P31"--> c7
v3 --"wdt:P625"--> v9
v3 --"wdt:P17"--> c10
v5 --"wdt:P31"--> c11
v5 --"wdt:P625"--> v10
v5 --"wdt:P17"--> c10
bind1[/"http://www.opengis.net/def/geosparql/function/distance(?location1,?location2)"/]
v9 --o bind1
v10 --o bind1
bind1 --as--o v11
bind3[/"min(?distance)"/]
v11 --o bind3
bind3 --as--o v11
v5 --"wdt:P31"--> c11
v5 --"wdt:P625"--> v10
v5 --"wdt:P17"--> c10
bind4[/"http://www.opengis.net/def/geosparql/function/distance(?location1,?location2)"/]
v9 --o bind4
v10 --o bind4
bind4 --as--o v11