query-cddcdd61d9ca4dcdac2245097c7399f4
14:57, 28 March 2023 (UTC)) talk (Vicarage in Manchester etc (Q111529535)Mancunicon whose location is given as Liverpool, or with a radius of 100km, (Q111529501)Eastcon like (Q1958056)science fiction convention Will give me places within 1km of Liverpool. But I can't uncomment the lines above to use the indirection, to find Is this what you're after? I had to use geof:distance instead of wikibase:around...
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 geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?item_location ?distance WHERE {
{
SELECT ?what_is_thing ?coords_of_thing ?target_distance WHERE {
VALUES ?thing { wd:Q111529510 }
VALUES ?target_distance { 100 }
?thing wdt:P31 ?what_is_thing .
# if there are no coordinates on the item then get them from the location statement
OPTIONAL { ?thing wdt:P625 ?coords_of_thing }
OPTIONAL { ?thing wdt:P276 ?location_of_thing . ?location_of_thing wdt:P625 ?coords_of_location_of_thing }
BIND(IF(BOUND(?coords_of_thing), ?coords_of_thing, ?coords_of_location_of_thing) AS ?coords_of_thing)
} } ?item wdt:P31* ?what_is_thing .
# if there are no coordinates on the item then get them from the location statement
OPTIONAL { ?item wdt:P625 ?item_location }
OPTIONAL { ?item wdt:P276 [ wdt:P625 ?loc1 ] }
BIND(IF(BOUND(?item_location), ?item_location, ?loc1) AS ?item_location)
#
BIND(geof:distance(?coords_of_thing, ?item_location) as ?distance)
FILTER (?distance <= ?target_distance )
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}