query-4dbac81d8beb57c8eedc26f6ebf03f04

rq turtle/ttl

Public Transport Île-de-France, France

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




WHERE {
  {  {
  SELECT ?item (SAMPLE(?coordinates) AS ?coordinates) (SAMPLE(?lat1) AS ?lat1) (SAMPLE(?lon1) AS ?lon1) WHERE { #(SAMPLE(?image) AS ?image)
    {?item wdt:P16 wd:Q50716} 
      UNION 
    {?item wdt:P16 wd:Q1142114}
      UNION 
    {?item wdt:P361 wd:Q216125} .
    ?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:P16 wd:Q50716} 
      UNION 
    {?item wdt:P16 wd:Q1142114}
      UNION 
    {?item wdt:P361 wd:Q216125} .
    ?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:P16 wd:Q50716} 
      UNION 
    {?nextstation wdt:P16 wd:Q1142114}
      UNION     
    {?nextstation wdt:P361 wd:Q216125} .
    ?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:P16 wd:Q50716} 
      UNION 
   {?nextstationstatement (pq:P81|pq:P1192) ?connect . ?connect wdt:P16 wd:Q1142114} 
      UNION 
    {?nextstationstatement (pq:P81|pq:P1192) ?connect . ?connect wdt:P361 wd:Q216125}  .
    ?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; v9("?connect") v6("?coordinates"):::projected v1("?item"):::projected v6("?lat1") v8("?lat2") v12("?line"):::projected v6("?lon1") v8("?lon2") v5("?nextstation") v8("?nextstationstatement") v10("?rgb"):::projected v11("?str") a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) a8((" ")) a9((" ")) a10((" ")) a11((" ")) a12((" ")) c3(["wd:Q1142114"]):::iri c17(["bd:serviceParam"]):::iri c2(["wd:Q50716"]):::iri c5(["wd:Q216125"]):::iri c19(["#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 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; v1 --"p:direct/P361"--> c5 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P16"--> c3 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P16"--> c2 end union1r <== or ==> union1l end v1 --"p:direct/P625"--> v6 v1 --"p:P625"--> a5 a5 --"p:statement/value/P625"--> a6 a6 --"wikibase:geoLatitude"--> v6 v1 --"p:P625"--> a7 a7 --"p:statement/value/P625"--> a8 a8 --"wikibase:geoLongitude"--> v6 bind4[/"sample(?coordinates)"/] v6 --o bind4 bind4 --as--o v6 bind5[/"sample(?lat1)"/] v6 --o bind5 bind5 --as--o v6 bind6[/"sample(?lon1)"/] v6 --o bind6 bind6 --as--o v6 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; v5 --"p:direct/P361"--> c5 end subgraph union4r[" "] style union4r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P16"--> c3 end union4r <== or ==> union4l end end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P16"--> c2 end union3r <== or ==> union3l end v5 --"p:P625"--> a9 a9 --"p:statement/value/P625"--> a10 a10 --"wikibase:geoLatitude"--> v8 v5 --"p:P625"--> a11 a11 --"p:statement/value/P625"--> a12 a12 --"wikibase:geoLongitude"--> v8 bind9[/"sample(?lat2)"/] v8 --o bind9 bind9 --as--o v8 bind10[/"sample(?lon2)"/] v8 --o bind10 bind10 --as--o v8 v1 --"p:P197"--> v8 v8 --"p:statement/P197"--> v5 subgraph union5[" Union "] subgraph union5l[" "] style union5l fill:#abf,stroke-dasharray: 3 3; subgraph union6[" Union "] subgraph union6l[" "] style union6l fill:#abf,stroke-dasharray: 3 3; subgraph union7[" Union "] subgraph union7l[" "] style union7l fill:#abf,stroke-dasharray: 3 3; v8 --"p:qualifier/P1192"--> v9 end subgraph union7r[" "] style union7r fill:#abf,stroke-dasharray: 3 3; v8 --"p:qualifier/P81"--> v9 end union7r <== or ==> union7l end v9 --"p:direct/P361"--> c5 end subgraph union6r[" "] style union6r fill:#abf,stroke-dasharray: 3 3; subgraph union8[" Union "] subgraph union8l[" "] style union8l fill:#abf,stroke-dasharray: 3 3; v8 --"p:qualifier/P1192"--> v9 end subgraph union8r[" "] style union8r fill:#abf,stroke-dasharray: 3 3; v8 --"p:qualifier/P81"--> v9 end union8r <== or ==> union8l end v9 --"p:direct/P16"--> c3 end union6r <== or ==> union6l end end subgraph union5r[" "] style union5r fill:#abf,stroke-dasharray: 3 3; subgraph union9[" Union "] subgraph union9l[" "] style union9l fill:#abf,stroke-dasharray: 3 3; v8 --"p:qualifier/P1192"--> v9 end subgraph union9r[" "] style union9r fill:#abf,stroke-dasharray: 3 3; v8 --"p:qualifier/P81"--> v9 end union9r <== or ==> union9l end v9 --"p:direct/P16"--> c2 end union5r <== or ==> union5l end v9 --"p:direct/P465"--> v10 bind11[/"concat('LINESTRING (',str(?lon1),' ',str(?lat1),',',str(?lon2),' ',str(?lat2),')')"/] v6 --o bind11 v6 --o bind11 v8 --o bind11 v8 --o bind11 bind11 --as--o v11 bind12[/"STRDT(?str,'geo:wktLiteral')"/] v11 --o bind12 bind12 --as--o v12 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; 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; v1 --"p:direct/P361"--> c5 end subgraph union11r[" "] style union11r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P16"--> c3 end union11r <== or ==> union11l end end subgraph union10r[" "] style union10r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P16"--> c2 end union10r <== or ==> union10l end v1 --"p:direct/P625"--> v6 v1 --"p:P625"--> a1 a1 --"p:statement/value/P625"--> a2 a2 --"wikibase:geoLatitude"--> v6 v1 --"p:P625"--> a3 a3 --"p:statement/value/P625"--> a4 a4 --"wikibase:geoLongitude"--> v6 bind16[/"sample(?coordinates)"/] v6 --o bind16 bind16 --as--o v6 bind17[/"sample(?lat1)"/] v6 --o bind17 bind17 --as--o v6 bind18[/"sample(?lon1)"/] v6 --o bind18 bind18 --as--o v6 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c17 --"wikibase:language"--> c19 end