query-220d8968b823647c21ef47de51975d05
TODO
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?type (SAMPLE (DISTINCT ?sta) as ?subtypeLabel) WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en,fr,de,es,pt,pl,nl,cs". }
{
SELECT ?classes1 ?classes2 #?range ?props
WHERE {
VALUES ?classes1 {
wd:Q1785071 # fort
}
VALUES ?classes2 {
wd:Q91122 # bunker
}
VALUES ?range {"15"}
} } wd:Q1180981 wdt:P17 ?country.
?item wdt:P17 ?country.
{?item wdt:P31/wdt:P279* ?classes1 .} UNION
{?item wdt:P31/wdt:P279* ?classes2 .}
{ {wd:Q1180981 wdt:P625 ?loc1.} UNION
{wd:Q1180981 wdt:P276 ?loc.
?loc wdt:P625 ?loc1} }
SERVICE wikibase:around {
?item wdt:P625 ?loc2.
bd:serviceParam wikibase:center ?loc1.
bd:serviceParam wikibase:radius "15".
bd:serviceParam wikibase:distance ?dist.
}
MINUS {VALUES ?item {wd:Q1180981} } # itself
OPTIONAL {?item wdt:P1448 ?labellist. FILTER (lang(?labellist) = "mul")} # official name
{SERVICE wikibase:label {bd:serviceParam wikibase:language "en" . ?item rdfs:label ?label1} }
}
#GROUP by ?item ?starts ?ends ?dist ?label1 ?type
GROUP by ?item ?type ?label1
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?classes1")
v3("?classes2")
v5("?country")
v10("?dist")
v11("?item"):::projected
v11("?label1")
v1("?labellist")
v8("?loc")
v7("?loc1")
v9("?loc2")
v4("?range")
v12("?sta"):::projected
v13("?subtypeLabel")
a1((" "))
a2((" "))
c15(["15"]):::literal
c18(["en"]):::literal
c5(["en-GB,en,fr,de,es,pt,pl,nl,cs"]):::literal
c3(["bd:serviceParam"]):::iri
c6(["wd:Q1180981"]):::iri
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c3 --"wikibase:language"--> c5
end
bind0[/VALUES ?classes1/]
bind0-->v2
bind00(["wd:Q1785071"])
bind00 --> bind0
bind1[/VALUES ?classes2/]
bind1-->v3
bind10(["wd:Q91122"])
bind10 --> bind1
bind2[/VALUES ?range/]
bind2-->v4
bind20(["15"])
bind20 --> bind2
c6 --"wdt:P17"--> v5
v11 --"wdt:P17"--> v5
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v11 --"wdt:P31"--> a2
a2 --"wdt:P279"--> v3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v11 --"wdt:P31"--> a1
a1 --"wdt:P279"--> v2
end
union0r <== or ==> union0l
end
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
c6 --"wdt:P276"--> v8
v8 --"wdt:P625"--> v7
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
c6 --"wdt:P625"--> v7
end
union1r <== or ==> union1l
end
subgraph s2["http://wikiba.se/ontology#around"]
style s2 stroke-width:4px;
v11 --"wdt:P625"--> v9
c3 --"wikibase:center"--> v7
c3 --"wikibase:radius"--> c15
c3 --"wikibase:distance"--> v10
end
subgraph minus3["MINUS"]
style minus3 stroke-width:6px,fill:pink,stroke:red;
bind4[/VALUES ?item/]
bind4-->v11
bind40(["wd:Q1180981"])
bind40 --> bind4
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v11 -."wdt:P1448".-> v1
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c3 --"wikibase:language"--> c18
v11 --"rdfs:label"--> v11
end
bind6[/"sample(?sta)"/]
v12 --o bind6
bind6 --as--o v13