query-fc5f8b97e9a90e8b28a9160dea8b1626

rq turtle/ttl

TODO

Use at

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 ?image ?opening ?rgb




WHERE {
  {  {
  SELECT ?item (SAMPLE(?coordinates) AS ?coordinates) (SAMPLE(?image) AS ?image) ?opening WHERE {
    ?item wdt:P361 wd:Q260870 .
    ?item wdt:P31/wdt:P279* wd:Q55488 .
    ?item wdt:P625 ?coordinates  .
    OPTIONAL { ?item wdt:P18 ?image }.
    OPTIONAL {?item wdt:P1619 ?opening } .
  } GROUP BY ?item ?opening
}} UNION {  {
  SELECT ?line ?connect ?rgb WHERE {
     {
  SELECT ?item (SAMPLE(?coordinates) AS ?coordinates) (SAMPLE(?image) AS ?image) ?opening WHERE {
    ?item wdt:P361 wd:Q260870 .
    ?item wdt:P31/wdt:P279* wd:Q55488 .
    ?item wdt:P625 ?coordinates  .
    OPTIONAL { ?item wdt:P18 ?image }.
    OPTIONAL {?item wdt:P1619 ?opening } .
  } GROUP BY ?item ?opening
}.
    ?item p:P197 ?nextstationstatement .
    ?nextstationstatement ps:P197 ?nextstation .
    ?nextstationstatement pq:P81 ?connect . ?connect wdt:P361 wd:Q260870  . 
    ?connect wdt:P465 ?rgb .
    FILTER(STR(?item) < STR(?nextstation)) . 
    ?item p:P625 / psv:P625 / wikibase:geoLatitude ?lat1 .
    ?item p:P625 / psv:P625 / wikibase:geoLongitude ?lon1 .
    ?nextstation p:P625 / psv:P625 / wikibase:geoLatitude ?lat2 .
    ?nextstation p:P625 / psv:P625 / wikibase:geoLongitude ?lon2 . 
    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; v7("?connect") v6("?coordinates"):::projected v6("?image"):::projected v1("?item"):::projected v9("?lat1") v11("?lat2") v14("?line"):::projected v10("?lon1") v12("?lon2") v5("?nextstation") v6("?nextstationstatement") v4("?opening"):::projected v8("?rgb"):::projected v13("?str") a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) a8((" ")) a9((" ")) a10((" ")) c2(["wd:Q260870"]):::iri c18(["bd:serviceParam"]):::iri c5(["wd:Q55488"]):::iri c20(["#91;AUTO_LANGUAGE#93;,en"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; f0[["str(?item) < str(?nextstation)"]] f0 --> v1 f0 --> v5 v1 --"p:direct/P361"--> c2 v1 --"p:direct/P31"--> a2 a2 --"p:direct/P279"--> c5 v1 --"p:direct/P625"--> v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P18".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P1619".-> v4 end bind3[/"sample(?coordinates)"/] v6 --o bind3 bind3 --as--o v6 bind4[/"sample(?image)"/] v6 --o bind4 bind4 --as--o v6 v1 --"p:P197"--> v6 v6 --"p:statement/P197"--> v5 v6 --"p:qualifier/P81"--> v7 v7 --"p:direct/P361"--> c2 v7 --"p:direct/P465"--> v8 v1 --"p:P625"--> a3 a3 --"p:statement/value/P625"--> a4 a4 --"wikibase:geoLatitude"--> v9 v1 --"p:P625"--> a5 a5 --"p:statement/value/P625"--> a6 a6 --"wikibase:geoLongitude"--> v10 v5 --"p:P625"--> a7 a7 --"p:statement/value/P625"--> a8 a8 --"wikibase:geoLatitude"--> v11 v5 --"p:P625"--> a9 a9 --"p:statement/value/P625"--> a10 a10 --"wikibase:geoLongitude"--> v12 bind5[/"concat('LINESTRING (',str(?lon1),' ',str(?lat1),',',str(?lon2),' ',str(?lat2),')')"/] v10 --o bind5 v9 --o bind5 v12 --o bind5 v11 --o bind5 bind5 --as--o v13 bind6[/"STRDT(?str,'geo:wktLiteral')"/] v13 --o bind6 bind6 --as--o v14 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P361"--> c2 v1 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c5 v1 --"p:direct/P625"--> v6 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P18".-> v6 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P1619".-> v4 end bind9[/"sample(?coordinates)"/] v6 --o bind9 bind9 --as--o v6 bind10[/"sample(?image)"/] v6 --o bind10 bind10 --as--o v6 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c18 --"wikibase:language"--> c20 end