query-42914356ca0f1196c9db978a7a0e00d4

rq turtle/ttl

Stations in Québec closer than 1 km from a bridge of a length over 100 m

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Stations in Québec closer than 1 km from a bridge of a length over 100 m 
#defaultView:Map
SELECT DISTINCT ?station ?coordonn_es_g_ographiques WHERE {

  # Bridges
  {
    SELECT ?bridge WHERE { ?bridge (wdt:P31/wdt:P279*) wd:Q12280. }
  }
  ?bridge wdt:P131* wd:Q176. # in QC

  # with a length < 100 m
  ?bridge wdt:P2043 ?length.
  FILTER(?length > 100)

  # Find station within 1km of these bridges 
  ?bridge wdt:P625 ?bridgeLoc 
  SERVICE wikibase:around {
    ?station wdt:P625 ?location .
    bd:serviceParam wikibase:center ?bridgeLoc .
    bd:serviceParam wikibase:radius "1" . # within 1 km radius
  } .
  # is close from a Wx station
  FILTER EXISTS { ?station wdt:P31/wdt:P279* wd:Q190107 } .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?station wdt:P625 ?coordonn_es_g_ographiques. }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?bridge") v4("?bridgeLoc") v6("?coordonn_es_g_ographiques"):::projected v2("?length") v5("?location") v1("?station"):::projected a2((" ")) a1((" ")) c5(["wd:Q12280"]):::iri c14(["1"]):::literal c3(["wd:Q190107"]):::iri c11(["bd:serviceParam"]):::iri c17(["#91;AUTO_LANGUAGE#93;,en"]):::literal c7(["wd:Q176"]):::iri f0[[" "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P31"--> e0a1 e0a1 --"wdt:P279"--> e0c3 e0v1("?station"):::projected e0a1((" ")):::projected e0c3(["wd:Q190107"]):::iri end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> a1 f0 --> c2 f0 --> c3 v1 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 f1[["?length > '100^^xsd:integer'"]] f1 --> v2 v3 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c5 v3 --"wdt:P131"--> c7 v3 --"wdt:P2043"--> v2 v3 --"wdt:P625"--> v4 subgraph s1["http://wikiba.se/ontology#around"] style s1 stroke-width:4px; v1 --"wdt:P625"--> v5 c11 --"wikibase:center"--> v4 c11 --"wikibase:radius"--> c14 end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c11 --"wikibase:language"--> c17 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P625".-> v6 end