User:GodeNehler/Stuttgart U
Jump to navigation
Jump to search
Try it!
Query für die U-Bahn Stuttgart
U-Bahn Stuttgart, Germany[edit]
#defaultView:Map{"hide":["?coordinates", "?line", "?rgb"]}
SELECT DISTINCT ?coordinates ?line ?item ?itemLabel ?connectLabel ?image ?rgb
WITH {
SELECT ?item (SAMPLE(?coordinates) AS ?coordinates) (SAMPLE(?image) AS ?image) (SAMPLE(?lat1) AS ?lat1) (SAMPLE(?lon1) AS ?lon1) (SAMPLE(?opening) AS ?opening) WHERE {
{?item (wdt:P16|wdt:P361) wd:Q569933} .
?item wdt:P625 ?coordinates .
?item p:P625 / psv:P625 / wikibase:geoLatitude ?lat1 .
?item p:P625 / psv:P625 / wikibase:geoLongitude ?lon1 .
OPTIONAL { ?item wdt:P18 ?image }.
} GROUP BY ?item
} AS %stations
WITH {
SELECT ?nextstation (SAMPLE(?lat2) AS ?lat2) (SAMPLE(?lon2) AS ?lon2) WHERE {
{?nextstation (wdt:P16|wdt:P361) wd:Q569933} .
?nextstation p:P625 / psv:P625 / wikibase:geoLatitude ?lat2 .
?nextstation p:P625 / psv:P625 / wikibase:geoLongitude ?lon2 .
} GROUP BY ?nextstation
} AS %nextstations
WITH {
SELECT ?line ?connect ?rgb WHERE {
INCLUDE %stations .
INCLUDE %nextstations .
?item p:P197 ?nextstationstatement .
?nextstationstatement ps:P197 ?nextstation .
{?nextstationstatement pq:P1192 ?connect . ?connect (wdt:P16|wdt:P361) wd:Q569933} .
?connect wdt:P465 ?rgb .
FILTER(STR(?item) < STR(?nextstation)) .
BIND(CONCAT('LINESTRING (', STR(?lon1), ' ', STR(?lat1), ',', STR(?lon2), ' ', STR(?lat2), ')') AS ?str) .
BIND(STRDT(?str, geo:wktLiteral) AS ?line)
}
} AS %lines
WHERE {
{ INCLUDE %stations } UNION { INCLUDE %lines } .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}