query-39232462c7fb20f5cc8efbda56a74c59
Partnerstädte Visualisierung
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 geo: <http://www.opengis.net/ont/geosparql#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"hide": ["?city_coords_", "?sister_city_coords_", "?line"]}
SELECT ?city ?cityLabel ?sister_city ?sister_cityLabel ?sister_city_countryLabel ?city_coords_ ?sister_city_coords_ ?distance ?line
WHERE {
{
SELECT ?city ?sister_city (SAMPLE(?city_coords) AS ?city_coords_) (SAMPLE(?sister_city_coords) AS ?sister_city_coords_) ?sister_city_country WHERE {
?city wdt:P31/wdt:P279* wd:Q515;
wdt:P190 ?sister_city;
wdt:P17 wd:Q183.
OPTIONAL { ?city wdt:P625 ?city_coords. }
OPTIONAL { ?sister_city wdt:P625 ?sister_city_coords. }
OPTIONAL { ?sister_city wdt:P17 ?sister_city_country. }
}
GROUP BY ?city ?sister_city ?sister_city_country
}
BIND(geof:distance(?city_coords_, ?sister_city_coords_) AS ?distance)
BIND(STRDT(CONCAT("LINESTRING(", STRBEFORE(STRAFTER(STR(?city_coords_), "Point("), ")"), ", ", STRBEFORE(STRAFTER(STR(?sister_city_coords_), "Point("), ")"), ")"), geo:wktLiteral) AS ?line)
SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en". }
}
ORDER BY ?distance
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?city"):::projected
v4("?city_coords")
v7("?city_coords_"):::projected
v9("?distance"):::projected
v9("?line"):::projected
v3("?sister_city"):::projected
v5("?sister_city_coords")
v8("?sister_city_coords_"):::projected
v6("?sister_city_country")
a1((" "))
c9(["bd:serviceParam"]):::iri
c3(["wd:Q515"]):::iri
c6(["wd:Q183"]):::iri
c11(["de,en"]):::literal
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c3
v2 --"wdt:P190"--> v3
v2 --"wdt:P17"--> c6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P625".-> v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P625".-> v5
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P17".-> v6
end
bind2[/"sample(?city_coords)"/]
v4 --o bind2
bind2 --as--o v7
bind3[/"sample(?sister_city_coords)"/]
v5 --o bind3
bind3 --as--o v8
bind4[/"http://www.opengis.net/def/function/geosparql/distance(?city_coords_,?sister_city_coords_)"/]
v7 --o bind4
v8 --o bind4
bind4 --as--o v9
bind5[/"STRDT(concat('LINESTRING(',substring-before(substring-after(str(?city_coords_),'Point('),')'),', ',substring-before(substring-after(str(?sister_city_coords_),'Point('),')'),')'),'geo:wktLiteral')"/]
v7 --o bind5
v8 --o bind5
bind5 --as--o v9
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
end