582
edits
Line 1,614: | Line 1,614: | ||
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/> | PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/> | ||
#defaultView:Map | #defaultView:Map | ||
SELECT distinct ?item ?itemLabel ?locationLabel ?location ?wikidata ?wd_geo | SELECT distinct ?item ?itemLabel ?locationLabel ?location ?adminterr ?wikidata ?wd_geo | ||
WHERE { | WHERE { | ||
?item bnwdt:P12 bnwd:Q38 . | ?item bnwdt:P12 bnwd:Q38 . | ||
?item bnwdt:P2 ?location . # item has property P2 location | ?item bnwdt:P2 ?location . # item has property P2 location | ||
optional { ?location bnwdt:P33 ?adminterr . | |||
?adminterr bnwdt:P117 ?wsa . # and has wikidata id | |||
bind(iri(concat("http://www.wikidata.org/entity/", str(?wsa))) as ?wikidataa) . | |||
SERVICE <https://query.wikidata.org/sparql> { | |||
?wikidataa wdt:P625 ?wd_geo2 . | |||
} # /wikidata service | |||
} | |||
optional { | |||
?location bnwdt:P117 ?ws . # and has wikidata id | ?location bnwdt:P117 ?ws . # and has wikidata id | ||
bind(iri(concat("http://www.wikidata.org/entity/", str(?ws))) as ?wikidata) . | bind(iri(concat("http://www.wikidata.org/entity/", str(?ws))) as ?wikidata) . | ||
SERVICE <https://query.wikidata.org/sparql> { | SERVICE <https://query.wikidata.org/sparql> { | ||
?wikidata wdt:P625 ? | ?wikidata wdt:P625 ?wd_geo1 . | ||
} # /wikidata service | } # /wikidata service | ||
} | |||
BIND(COALESCE(?wd_geo1, ?wd_geo2) AS ?wd_geo). # if geo1 available use that, then try geo2 | |||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". } | SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". } |
edits