query-78343cbe81e67d0d004fffab50eff4ea

rq turtle/ttl

Oslo metro

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
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#>
# Oslo metro
#defaultView:Map{"hide": ["?rgb", "?coord1","?line"]}
SELECT DISTINCT ?station1 ?station1Label ?coord1 ?nowiki ?rgb ?line
WHERE {
  ?class wdt:P279* wd:Q928830 .
  ?station1 p:P31 ?st1inst_st;
    wdt:P16 wd:Q24492;
    wdt:P625 ?coord1.
  ?st1inst_st ps:P31 ?class;
    a wikibase:BestRank .
  MINUS { ?st1inst_st pq:P582 [] . }
  MINUS { ?station1 wdt:P576 [] . }
  OPTIONAL { ?station1 wdt:P1192/wdt:P465 ?rgb_ . }
  OPTIONAL {
    ?station1 wdt:P197 ?station2.
    ?station1 p:P625 [ ps:P625 []; psv:P625 [ wikibase:geoLongitude ?coord1lon; wikibase:geoLatitude ?coord1lat ] ] .
    ?station2 p:P625 [ ps:P625 []; psv:P625 [ wikibase:geoLongitude ?coord2lon; wikibase:geoLatitude ?coord2lat ] ] .
    BIND(CONCAT('LINESTRING (', STR(?coord1lon), ' ', STR(?coord1lat), ',', STR(?coord2lon), ' ', STR(?coord2lat), ')') AS ?str) .
    BIND(STRDT(?str, geo:wktLiteral) AS ?line) .
  }
  OPTIONAL {
    ?nowiki schema:about ?station1 ;
      schema:isPartOf <https://no.wikipedia.org/> .
  }
  BIND (COALESCE(?rgb_, "000000") AS ?rgb)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "nb,en" . }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?class") v4("?coord1"):::projected v8("?coord1lat") v7("?coord1lon") v10("?coord2lat") v9("?coord2lon") v12("?line"):::projected v13("?nowiki"):::projected v14("?rgb"):::projected v5("?rgb_") v3("?st1inst_st") v2("?station1"):::projected v6("?station2") v11("?str") a1((" ")) a2((" ")) a5((" ")) a3((" ")) a4((" ")) a6((" ")) a7((" ")) a9((" ")) a8((" ")) c5(["wd:Q24492"]):::iri c2(["wd:Q928830"]):::iri c24(["bd:serviceParam"]):::iri c22([https://no.wikipedia.org/]):::iri c26(["nb,en"]):::literal c9(["wikibase:BestRank"]):::iri v1 --"p:direct/P279"--> c2 v2 --"p:P31"--> v3 v2 --"p:direct/P16"--> c5 v2 --"p:direct/P625"--> v4 v3 --"p:statement/P31"--> v1 v3 --"a"--> c9 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v3 --"p:qualifier/P582"--> a1 end subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P576"--> a2 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P1192".-> a3 a3 --"p:direct/P465"--> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P197".-> v6 a4 --"p:statement/P625"--> a5 a6 --"wikibase:geoLongitude"--> v7 a6 --"wikibase:geoLatitude"--> v8 a4 --"p:statement/value/P625"--> a6 v2 --"p:P625"--> a4 a7 --"p:statement/P625"--> a8 a9 --"wikibase:geoLongitude"--> v9 a9 --"wikibase:geoLatitude"--> v10 a7 --"p:statement/value/P625"--> a9 v6 --"p:P625"--> a7 bind2[/"concat('LINESTRING (',str(?coord1lon),' ',str(?coord1lat),',',str(?coord2lon),' ',str(?coord2lat),')')"/] v7 --o bind2 v8 --o bind2 v9 --o bind2 v10 --o bind2 bind2 --as--o v11 bind3[/"STRDT(?str,'geo:wktLiteral')"/] v11 --o bind3 bind3 --as--o v12 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v13 -."schema:about".-> v2 v13 --"schema:isPartOf"--> c22 end bind4[/"?rgb_'000000'"/] v5 --o bind4 bind4 --as--o v14 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c24 --"wikibase:language"--> c26 end