query-9d3e2d17a29eb1c84ba6d393e459edd7
TODO
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 geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?coord ?item2 ?item2Label ?coord2 ?dist
{
{
SELECT ?item ?coord ?item2 ?coord2 ?dist
{
{
SELECT DISTINCT ?item (SAMPLE(?coord_) AS ?coord)
{
?item wdt:P31 / wdt:P279 * wd:Q12323 . # Instance of Dam or subclass
?item wdt:P17 wd:Q17 . # In Japan
?item wdt:P625 ?coord_ .
BIND (geof:longitude(?coord_) AS ?long)
FILTER (?long > 136)
FILTER (?long < 138)
}
GROUP BY ?item
} {
SELECT (?item AS ?item2) (?coord AS ?coord2) {
{
SELECT DISTINCT ?item (SAMPLE(?coord_) AS ?coord)
{
?item wdt:P31 / wdt:P279 * wd:Q12323 . # Instance of Dam or subclass
?item wdt:P17 wd:Q17 . # In Japan
?item wdt:P625 ?coord_ .
BIND (geof:longitude(?coord_) AS ?long)
FILTER (?long > 136)
FILTER (?long < 138)
}
GROUP BY ?item
}}
}
FILTER (STR(?item) < STR(?item2))
BIND(geof:distance(?coord, ?coord2) as ?dist)
FILTER (?dist <= 10)
}
} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,ja" }
}
ORDER BY ?dist
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?coord"):::projected
v7("?coord2"):::projected
v5("?coord_")
v8("?dist"):::projected
v2("?item"):::projected
v7("?item2"):::projected
v7("?long")
a1((" "))
a2((" "))
c13(["#91;AUTO_LANGUAGE#93;,en,ja"]):::literal
c8(["wd:Q17"]):::iri
c11(["bd:serviceParam"]):::iri
c6(["wd:Q12323"]):::iri
f0[["?dist <= '10^^xsd:integer'"]]
f0 --> v8
f1[["str(?item) < str(?item2)"]]
f1 --> v2
f1 --> v7
f2[["?long < '138^^xsd:integer'"]]
f2 --> v7
f3[["?long > '136^^xsd:integer'"]]
f3 --> v7
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c6
v2 --"wdt:P17"--> c8
v2 --"wdt:P625"--> v5
bind4[/"http://www.opengis.net/def/function/geosparql/longitude(?coord_)"/]
v5 --o bind4
bind4 --as--o v7
bind6[/"sample(?coord_)"/]
v5 --o bind6
bind6 --as--o v7
f7[["?long < '138^^xsd:integer'"]]
f7 --> v7
f8[["?long > '136^^xsd:integer'"]]
f8 --> v7
v2 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c6
v2 --"wdt:P17"--> c8
v2 --"wdt:P625"--> v5
bind9[/"http://www.opengis.net/def/function/geosparql/longitude(?coord_)"/]
v5 --o bind9
bind9 --as--o v7
bind11[/"sample(?coord_)"/]
v5 --o bind11
bind11 --as--o v7
bind12[/"?item"/]
v2 --o bind12
bind12 --as--o v7
bind13[/"?coord"/]
v7 --o bind13
bind13 --as--o v7
bind14[/"http://www.opengis.net/def/function/geosparql/distance(?coord,?coord2)"/]
v7 --o bind14
v7 --o bind14
bind14 --as--o v8
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end