query-2e07ef52c30834652250d18739c376fe
London Over- and Underground, England, UK
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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"hide":["?coordinates", "?line", "?rgb"]}
SELECT DISTINCT ?coordinates ?line ?item ?itemLabel ?connectLabel ?rgb #?image
WHERE {
{ {
SELECT ?item (SAMPLE(?coordinates) AS ?coordinates) (SAMPLE(?lat1) AS ?lat1) (SAMPLE(?lon1) AS ?lon1) WHERE { #(SAMPLE(?image) AS ?image)
{?item (wdt:P361|wdt:P16) wd:Q20075} #Underground / OK
UNION
{?item (wdt:P361|wdt:P16) wd:Q746021} #London Overground / OK
UNION
{?item (wdt:P361|wdt:P16) wd:Q216360} #Dockland Light railway / OK
UNION
{?item (wdt:P361|wdt:P16) wd:Q732649} #Crossrail / OK
UNION
{?item (wdt:P361|wdt:P16) wd:Q786032} . #Tramlink / OK
?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
}} UNION { {
SELECT ?line ?connect ?rgb WHERE {
{
SELECT ?item (SAMPLE(?coordinates) AS ?coordinates) (SAMPLE(?lat1) AS ?lat1) (SAMPLE(?lon1) AS ?lon1) WHERE { #(SAMPLE(?image) AS ?image)
{?item (wdt:P361|wdt:P16) wd:Q20075} #Underground / OK
UNION
{?item (wdt:P361|wdt:P16) wd:Q746021} #London Overground / OK
UNION
{?item (wdt:P361|wdt:P16) wd:Q216360} #Dockland Light railway / OK
UNION
{?item (wdt:P361|wdt:P16) wd:Q732649} #Crossrail / OK
UNION
{?item (wdt:P361|wdt:P16) wd:Q786032} . #Tramlink / OK
?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
}.
{
SELECT ?nextstation (SAMPLE(?lat2) AS ?lat2) (SAMPLE(?lon2) AS ?lon2) WHERE {
{?nextstation (wdt:P361|wdt:P16) wd:Q20075} #Underground / OK
UNION
{?nextstation (wdt:P361|wdt:P16) wd:Q746021} #London Overground / OK
UNION
{?nextstation (wdt:P361|wdt:P16) wd:Q216360} #Dockland Light railway / OK
UNION
{?nextstation (wdt:P361|wdt:P16) wd:Q732649} #Crossrail / OK
UNION
{?nextstation (wdt:P361|wdt:P16) wd:Q786032} . #Tramlink / PK
?nextstation p:P625 / psv:P625 / wikibase:geoLatitude ?lat2 .
?nextstation p:P625 / psv:P625 / wikibase:geoLongitude ?lon2 .
} GROUP BY ?nextstation
}.
?item p:P197 ?nextstationstatement .
?nextstationstatement ps:P197 ?nextstation .
{?nextstationstatement (pq:P81|pq:P1192) ?connect . ?connect (wdt:P361|wdt:P16) wd:Q20075} #Underground / OK
UNION
{?nextstationstatement (pq:P81|pq:P1192) ?connect . ?connect (wdt:P361|wdt:P16) wd:Q746021} #London Overground / OK
UNION
{?nextstationstatement (pq:P81|pq:P1192) ?connect . ?connect (wdt:P361|wdt:P16) wd:Q216360} #Dockland Light railway / OK
UNION
{?nextstationstatement (pq:P81|pq:P1192) ?connect . ?connect (wdt:P361|wdt:P16) wd:Q732649} #Crossrail / OK
UNION
{?nextstationstatement (pq:P81|pq:P1192) ?connect . ?connect (wdt:P361|wdt:P16) wd:Q786032} . #Tramlink / partly OK
#TIMEOUT
?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)
}
} } .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v10("?connect")
v7("?coordinates"):::projected
v5("?image")
v1("?item"):::projected
v7("?lat1")
v9("?lat2")
v13("?line"):::projected
v7("?lon1")
v9("?lon2")
v6("?nextstation")
v9("?nextstationstatement")
v11("?rgb"):::projected
v12("?str")
a1((" "))
a2((" "))
a3((" "))
a4((" "))
a5((" "))
a6((" "))
a7((" "))
a8((" "))
a9((" "))
a10((" "))
a11((" "))
a12((" "))
c2(["wd:Q20075"]):::iri
c4(["wd:Q746021"]):::iri
c6(["wd:Q732649"]):::iri
c5(["wd:Q216360"]):::iri
c20(["bd:serviceParam"]):::iri
c22(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c7(["wd:Q786032"]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
f0[["str(?item) < str(?nextstation)"]]
f0 --> v1
f0 --> v6
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
subgraph union3[" Union "]
subgraph union3l[" "]
style union3l fill:#abf,stroke-dasharray: 3 3;
subgraph union4[" Union "]
subgraph union4l[" "]
style union4l fill:#abf,stroke-dasharray: 3 3;
subgraph union5[" Union "]
subgraph union5l[" "]
style union5l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P16"--> c7
end
subgraph union5r[" "]
style union5r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P361"--> c7
end
union5r <== or ==> union5l
end
end
subgraph union4r[" "]
style union4r fill:#abf,stroke-dasharray: 3 3;
subgraph union6[" Union "]
subgraph union6l[" "]
style union6l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P16"--> c6
end
subgraph union6r[" "]
style union6r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P361"--> c6
end
union6r <== or ==> union6l
end
end
union4r <== or ==> union4l
end
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
subgraph union7[" Union "]
subgraph union7l[" "]
style union7l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P16"--> c5
end
subgraph union7r[" "]
style union7r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P361"--> c5
end
union7r <== or ==> union7l
end
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
subgraph union8[" Union "]
subgraph union8l[" "]
style union8l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P16"--> c4
end
subgraph union8r[" "]
style union8r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P361"--> c4
end
union8r <== or ==> union8l
end
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
subgraph union9[" Union "]
subgraph union9l[" "]
style union9l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P16"--> c2
end
subgraph union9r[" "]
style union9r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P361"--> c2
end
union9r <== or ==> union9l
end
end
union1r <== or ==> union1l
end
v1 --"p:direct/P625"--> v7
v1 --"p:P625"--> a5
a5 --"p:statement/value/P625"--> a6
a6 --"wikibase:geoLatitude"--> v7
v1 --"p:P625"--> a7
a7 --"p:statement/value/P625"--> a8
a8 --"wikibase:geoLongitude"--> v7
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P18".-> v5
end
bind4[/"sample(?coordinates)"/]
v7 --o bind4
bind4 --as--o v7
bind5[/"sample(?lat1)"/]
v7 --o bind5
bind5 --as--o v7
bind6[/"sample(?lon1)"/]
v7 --o bind6
bind6 --as--o v7
subgraph union10[" Union "]
subgraph union10l[" "]
style union10l fill:#abf,stroke-dasharray: 3 3;
subgraph union11[" Union "]
subgraph union11l[" "]
style union11l fill:#abf,stroke-dasharray: 3 3;
subgraph union12[" Union "]
subgraph union12l[" "]
style union12l fill:#abf,stroke-dasharray: 3 3;
subgraph union13[" Union "]
subgraph union13l[" "]
style union13l fill:#abf,stroke-dasharray: 3 3;
subgraph union14[" Union "]
subgraph union14l[" "]
style union14l fill:#abf,stroke-dasharray: 3 3;
v6 --"p:direct/P16"--> c7
end
subgraph union14r[" "]
style union14r fill:#abf,stroke-dasharray: 3 3;
v6 --"p:direct/P361"--> c7
end
union14r <== or ==> union14l
end
end
subgraph union13r[" "]
style union13r fill:#abf,stroke-dasharray: 3 3;
subgraph union15[" Union "]
subgraph union15l[" "]
style union15l fill:#abf,stroke-dasharray: 3 3;
v6 --"p:direct/P16"--> c6
end
subgraph union15r[" "]
style union15r fill:#abf,stroke-dasharray: 3 3;
v6 --"p:direct/P361"--> c6
end
union15r <== or ==> union15l
end
end
union13r <== or ==> union13l
end
end
subgraph union12r[" "]
style union12r fill:#abf,stroke-dasharray: 3 3;
subgraph union16[" Union "]
subgraph union16l[" "]
style union16l fill:#abf,stroke-dasharray: 3 3;
v6 --"p:direct/P16"--> c5
end
subgraph union16r[" "]
style union16r fill:#abf,stroke-dasharray: 3 3;
v6 --"p:direct/P361"--> c5
end
union16r <== or ==> union16l
end
end
union12r <== or ==> union12l
end
end
subgraph union11r[" "]
style union11r fill:#abf,stroke-dasharray: 3 3;
subgraph union17[" Union "]
subgraph union17l[" "]
style union17l fill:#abf,stroke-dasharray: 3 3;
v6 --"p:direct/P16"--> c4
end
subgraph union17r[" "]
style union17r fill:#abf,stroke-dasharray: 3 3;
v6 --"p:direct/P361"--> c4
end
union17r <== or ==> union17l
end
end
union11r <== or ==> union11l
end
end
subgraph union10r[" "]
style union10r fill:#abf,stroke-dasharray: 3 3;
subgraph union18[" Union "]
subgraph union18l[" "]
style union18l fill:#abf,stroke-dasharray: 3 3;
v6 --"p:direct/P16"--> c2
end
subgraph union18r[" "]
style union18r fill:#abf,stroke-dasharray: 3 3;
v6 --"p:direct/P361"--> c2
end
union18r <== or ==> union18l
end
end
union10r <== or ==> union10l
end
v6 --"p:P625"--> a9
a9 --"p:statement/value/P625"--> a10
a10 --"wikibase:geoLatitude"--> v9
v6 --"p:P625"--> a11
a11 --"p:statement/value/P625"--> a12
a12 --"wikibase:geoLongitude"--> v9
bind9[/"sample(?lat2)"/]
v9 --o bind9
bind9 --as--o v9
bind10[/"sample(?lon2)"/]
v9 --o bind10
bind10 --as--o v9
v1 --"p:P197"--> v9
v9 --"p:statement/P197"--> v6
subgraph union19[" Union "]
subgraph union19l[" "]
style union19l fill:#abf,stroke-dasharray: 3 3;
subgraph union20[" Union "]
subgraph union20l[" "]
style union20l fill:#abf,stroke-dasharray: 3 3;
subgraph union21[" Union "]
subgraph union21l[" "]
style union21l fill:#abf,stroke-dasharray: 3 3;
subgraph union22[" Union "]
subgraph union22l[" "]
style union22l fill:#abf,stroke-dasharray: 3 3;
subgraph union23[" Union "]
subgraph union23l[" "]
style union23l fill:#abf,stroke-dasharray: 3 3;
v9 --"p:qualifier/P1192"--> v10
end
subgraph union23r[" "]
style union23r fill:#abf,stroke-dasharray: 3 3;
v9 --"p:qualifier/P81"--> v10
end
union23r <== or ==> union23l
end
subgraph union24[" Union "]
subgraph union24l[" "]
style union24l fill:#abf,stroke-dasharray: 3 3;
v10 --"p:direct/P16"--> c7
end
subgraph union24r[" "]
style union24r fill:#abf,stroke-dasharray: 3 3;
v10 --"p:direct/P361"--> c7
end
union24r <== or ==> union24l
end
end
subgraph union22r[" "]
style union22r fill:#abf,stroke-dasharray: 3 3;
subgraph union25[" Union "]
subgraph union25l[" "]
style union25l fill:#abf,stroke-dasharray: 3 3;
v9 --"p:qualifier/P1192"--> v10
end
subgraph union25r[" "]
style union25r fill:#abf,stroke-dasharray: 3 3;
v9 --"p:qualifier/P81"--> v10
end
union25r <== or ==> union25l
end
subgraph union26[" Union "]
subgraph union26l[" "]
style union26l fill:#abf,stroke-dasharray: 3 3;
v10 --"p:direct/P16"--> c6
end
subgraph union26r[" "]
style union26r fill:#abf,stroke-dasharray: 3 3;
v10 --"p:direct/P361"--> c6
end
union26r <== or ==> union26l
end
end
union22r <== or ==> union22l
end
end
subgraph union21r[" "]
style union21r fill:#abf,stroke-dasharray: 3 3;
subgraph union27[" Union "]
subgraph union27l[" "]
style union27l fill:#abf,stroke-dasharray: 3 3;
v9 --"p:qualifier/P1192"--> v10
end
subgraph union27r[" "]
style union27r fill:#abf,stroke-dasharray: 3 3;
v9 --"p:qualifier/P81"--> v10
end
union27r <== or ==> union27l
end
subgraph union28[" Union "]
subgraph union28l[" "]
style union28l fill:#abf,stroke-dasharray: 3 3;
v10 --"p:direct/P16"--> c5
end
subgraph union28r[" "]
style union28r fill:#abf,stroke-dasharray: 3 3;
v10 --"p:direct/P361"--> c5
end
union28r <== or ==> union28l
end
end
union21r <== or ==> union21l
end
end
subgraph union20r[" "]
style union20r fill:#abf,stroke-dasharray: 3 3;
subgraph union29[" Union "]
subgraph union29l[" "]
style union29l fill:#abf,stroke-dasharray: 3 3;
v9 --"p:qualifier/P1192"--> v10
end
subgraph union29r[" "]
style union29r fill:#abf,stroke-dasharray: 3 3;
v9 --"p:qualifier/P81"--> v10
end
union29r <== or ==> union29l
end
subgraph union30[" Union "]
subgraph union30l[" "]
style union30l fill:#abf,stroke-dasharray: 3 3;
v10 --"p:direct/P16"--> c4
end
subgraph union30r[" "]
style union30r fill:#abf,stroke-dasharray: 3 3;
v10 --"p:direct/P361"--> c4
end
union30r <== or ==> union30l
end
end
union20r <== or ==> union20l
end
end
subgraph union19r[" "]
style union19r fill:#abf,stroke-dasharray: 3 3;
subgraph union31[" Union "]
subgraph union31l[" "]
style union31l fill:#abf,stroke-dasharray: 3 3;
v9 --"p:qualifier/P1192"--> v10
end
subgraph union31r[" "]
style union31r fill:#abf,stroke-dasharray: 3 3;
v9 --"p:qualifier/P81"--> v10
end
union31r <== or ==> union31l
end
subgraph union32[" Union "]
subgraph union32l[" "]
style union32l fill:#abf,stroke-dasharray: 3 3;
v10 --"p:direct/P16"--> c2
end
subgraph union32r[" "]
style union32r fill:#abf,stroke-dasharray: 3 3;
v10 --"p:direct/P361"--> c2
end
union32r <== or ==> union32l
end
end
union19r <== or ==> union19l
end
v10 --"p:direct/P465"--> v11
bind11[/"concat('LINESTRING (',str(?lon1),' ',str(?lat1),',',str(?lon2),' ',str(?lat2),')')"/]
v7 --o bind11
v7 --o bind11
v9 --o bind11
v9 --o bind11
bind11 --as--o v12
bind12[/"STRDT(?str,'geo:wktLiteral')"/]
v12 --o bind12
bind12 --as--o v13
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
subgraph union33[" Union "]
subgraph union33l[" "]
style union33l fill:#abf,stroke-dasharray: 3 3;
subgraph union34[" Union "]
subgraph union34l[" "]
style union34l fill:#abf,stroke-dasharray: 3 3;
subgraph union35[" Union "]
subgraph union35l[" "]
style union35l fill:#abf,stroke-dasharray: 3 3;
subgraph union36[" Union "]
subgraph union36l[" "]
style union36l fill:#abf,stroke-dasharray: 3 3;
subgraph union37[" Union "]
subgraph union37l[" "]
style union37l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P16"--> c7
end
subgraph union37r[" "]
style union37r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P361"--> c7
end
union37r <== or ==> union37l
end
end
subgraph union36r[" "]
style union36r fill:#abf,stroke-dasharray: 3 3;
subgraph union38[" Union "]
subgraph union38l[" "]
style union38l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P16"--> c6
end
subgraph union38r[" "]
style union38r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P361"--> c6
end
union38r <== or ==> union38l
end
end
union36r <== or ==> union36l
end
end
subgraph union35r[" "]
style union35r fill:#abf,stroke-dasharray: 3 3;
subgraph union39[" Union "]
subgraph union39l[" "]
style union39l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P16"--> c5
end
subgraph union39r[" "]
style union39r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P361"--> c5
end
union39r <== or ==> union39l
end
end
union35r <== or ==> union35l
end
end
subgraph union34r[" "]
style union34r fill:#abf,stroke-dasharray: 3 3;
subgraph union40[" Union "]
subgraph union40l[" "]
style union40l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P16"--> c4
end
subgraph union40r[" "]
style union40r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P361"--> c4
end
union40r <== or ==> union40l
end
end
union34r <== or ==> union34l
end
end
subgraph union33r[" "]
style union33r fill:#abf,stroke-dasharray: 3 3;
subgraph union41[" Union "]
subgraph union41l[" "]
style union41l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P16"--> c2
end
subgraph union41r[" "]
style union41r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P361"--> c2
end
union41r <== or ==> union41l
end
end
union33r <== or ==> union33l
end
v1 --"p:direct/P625"--> v7
v1 --"p:P625"--> a1
a1 --"p:statement/value/P625"--> a2
a2 --"wikibase:geoLatitude"--> v7
v1 --"p:P625"--> a3
a3 --"p:statement/value/P625"--> a4
a4 --"wikibase:geoLongitude"--> v7
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P18".-> v5
end
bind16[/"sample(?coordinates)"/]
v7 --o bind16
bind16 --as--o v7
bind17[/"sample(?lat1)"/]
v7 --o bind17
bind17 --as--o v7
bind18[/"sample(?lon1)"/]
v7 --o bind18
bind18 --as--o v7
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c20 --"wikibase:language"--> c22
end