geocode/templates/sparql/lookup_by_name.sparql

15 lines
638 B
SPARQL
Raw Permalink Normal View History

2021-04-16 21:24:59 +01:00
SELECT DISTINCT ?item ?itemLabel ?commonsSiteLink ?commonsCat WHERE {
2023-10-13 16:49:18 +01:00
{ ?item rdfs:label {{ name }}@en } UNION { ?item skos:altLabel {{ name }}@en }
2021-04-16 21:24:59 +01:00
FILTER NOT EXISTS { ?item wdt:P31 wd:Q17362920 } .# ignore Wikimedia duplicated page
OPTIONAL { ?commonsSiteLink schema:about ?item ;
schema:isPartOf <https://commons.wikimedia.org/> }
OPTIONAL { ?item wdt:P373 ?commonsCat }
?item wdt:P625 ?coords .
FILTER(geof:distance(?coords, "Point({{ lon }} {{ lat }})"^^geo:wktLiteral) < 10)
FILTER(?commonsCat || ?commonsSiteLink)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}