query-edc78665384915ed8f65d293b93f4c54
Stops in straight line
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 p: <http://www.wikidata.org/prop/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?coords ?dist WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?item wdt:P81 wd:Q18165631; wdt:P625 ?coords.
filter(?item not in(wd:Q112825155))
VALUES ?station { wd:Q112823670 } . #select a station here, works also with any item having east, west, south and north bounds
?station p:P625 [ a wikibase:BestRank; ps:P625 ?coord_cible; psv:P625 ?cibleValue ] .
?cibleValue wikibase:geoLatitude ?lat_cible .
?cibleValue wikibase:geoLongitude ?lon_cible .
?item p:P625 [ a wikibase:BestRank; ps:P625 ?coord; psv:P625 ?cValue ] .
?cValue wikibase:geoLatitude ?lat .
?cValue wikibase:geoLongitude ?lon .
#FILTER( ?lat_cible > ?lat ) . #modify here to
FILTER( ?lon_cible < ?lon ) .
wd:Q112823927 wdt:P625 ?Burnley_St_Victoria_St_coord .
BIND(geof:distance(?Burnley_St_Victoria_St_coord, ?coords) as ?dist)
}
ORDER BY ?dist
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v13("?Burnley_St_Victoria_St_coord")
v11("?cValue")
v8("?cibleValue")
v10("?coord")
v7("?coord_cible")
v5("?coords"):::projected
v14("?dist"):::projected
v4("?item"):::projected
v12("?lat")
v9("?lat_cible")
v3("?lon")
v2("?lon_cible")
v6("?station")
a1((" "))
a2((" "))
c10(["wikibase:BestRank"]):::iri
c3(["bd:serviceParam"]):::iri
c7(["wd:Q18165631"]):::iri
c5(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c16(["wd:Q112823927"]):::iri
f0[["?lon_cible < ?lon"]]
f0 --> v2
f0 --> v3
f1[["?item != 'wd:Q112825155'"]]
f1 --> v4
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c3 --"wikibase:language"--> c5
end
v4 --"p:direct/P81"--> c7
v4 --"p:direct/P625"--> v5
bind2[/VALUES ?station/]
bind2-->v6
bind20(["wd:Q112823670"])
bind20 --> bind2
a1 --"a"--> c10
a1 --"p:statement/P625"--> v7
a1 --"p:statement/value/P625"--> v8
v6 --"p:P625"--> a1
v8 --"wikibase:geoLatitude"--> v9
v8 --"wikibase:geoLongitude"--> v2
a2 --"a"--> c10
a2 --"p:statement/P625"--> v10
a2 --"p:statement/value/P625"--> v11
v4 --"p:P625"--> a2
v11 --"wikibase:geoLatitude"--> v12
v11 --"wikibase:geoLongitude"--> v3
c16 --"p:direct/P625"--> v13
bind3[/"http://www.opengis.net/def/function/geosparql/distance(?Burnley_St_Victoria_St_coord,?coords)"/]
v13 --o bind3
v5 --o bind3
bind3 --as--o v14