query-bc5f5ad3d8833a0548f9574cbcea42a3
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?airport ?airportLabel ?country ?countryLabel WHERE
{
{
SELECT ?airport WHERE {
?airport (wdt:P31/wdt:P279*) wd:Q62447. #any aerodromes
optional {?airport wdt:P239|wdt:P238|wdt:P240|wdt:P5699|wdt:P5746|wdt:P5851|wdt:P6120 ?code.}#any airport code
filter(!Bound(?code)).#who does not have any airport code
} } FILTER NOT EXISTS { ?airport p:P239 [rdf:type wdno:P239].} #we do not want the ?item if ICAO has a <no value>
MINUS {?airport wdt:P576 [].} # remove items with P576 (dissolved, abolished or demolished) as a main property
MINUS {?airport wdt:P582 [].} # remove items with P582 (end date) as a main property
MINUS {?airport a wdno:P17.} #exclude airports that aren't physically based in a country
MINUS {?airport (wdt:P31/wdt:P279*) ?thing .
VALUES ?thing {wd:Q695850 wd:Q2265915 wd:Q1311670 wd:Q7373622 wd:Q782667 wd:Q502074 wd:Q44665966 wd:Q2071567} }
#except those special instances of unnotheworthy aerodromes
OPTIONAL {?airport wdt:P17 ?country. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr,de,kk". }
} order by ?countryLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?airport"):::projected
v3("?code")
v5("?country"):::projected
v1("?countryLabel"):::projected
v5("?thing")
a3((" "))
a4((" "))
a2((" "))
a1((" "))
a5((" "))
c2(["p:novalue/P239"]):::iri
c16(["p:novalue/P17"]):::iri
c6(["wd:Q62447"]):::iri
c21(["#91;AUTO_LANGUAGE#93;,en,fr,de,kk"]):::literal
c19(["bd:serviceParam"]):::iri
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0a1 --"a"--> e0c2
e0v1 --"p:P239"--> e0a1
e0v1("?airport"):::projected
e0a1((" ")):::projected
e0c2(["p:novalue/P239"]):::iri
end
f0--EXISTS--> f0e0
f0 --> a1
f0 --> c1
f0 --> c2
f0 --> v2
f0 --> c3
a1 --"a"--> c2
v2 --"p:P239"--> a1
f1[["not bound(?code)"]]
f1 --> v3
v2 --"p:direct/P31"--> a2
a2 --"p:direct/P279"--> c6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
subgraph union3[" Union "]
subgraph union3l[" "]
style union3l fill:#abf,stroke-dasharray: 3 3;
subgraph union4[" Union "]
subgraph union4l[" "]
style union4l fill:#abf,stroke-dasharray: 3 3;
subgraph union5[" Union "]
subgraph union5l[" "]
style union5l fill:#abf,stroke-dasharray: 3 3;
v2 -."p:direct/P6120".-> v3
end
subgraph union5r[" "]
style union5r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P5851"--> v3
end
union5r <== or ==> union5l
end
end
subgraph union4r[" "]
style union4r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P5746"--> v3
end
union4r <== or ==> union4l
end
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P5699"--> v3
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P240"--> v3
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P238"--> v3
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P239"--> v3
end
union0r <== or ==> union0l
end
end
subgraph minus2["MINUS"]
style minus2 stroke-width:6px,fill:pink,stroke:red;
v2 --"p:direct/P576"--> a3
end
subgraph minus3["MINUS"]
style minus3 stroke-width:6px,fill:pink,stroke:red;
v2 --"p:direct/P582"--> a4
end
subgraph minus4["MINUS"]
style minus4 stroke-width:6px,fill:pink,stroke:red;
v2 --"a"--> c16
end
subgraph minus5["MINUS"]
style minus5 stroke-width:6px,fill:pink,stroke:red;
v2 --"p:direct/P31"--> a5
a5 --"p:direct/P279"--> v5
bind6[/VALUES ?thing/]
bind6-->v5
bind60(["wd:Q695850"])
bind60 --> bind6
bind61(["wd:Q2265915"])
bind61 --> bind6
bind62(["wd:Q1311670"])
bind62 --> bind6
bind63(["wd:Q7373622"])
bind63 --> bind6
bind64(["wd:Q782667"])
bind64 --> bind6
bind65(["wd:Q502074"])
bind65 --> bind6
bind66(["wd:Q44665966"])
bind66 --> bind6
bind67(["wd:Q2071567"])
bind67 --> bind6
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P17".-> v5
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c19 --"wikibase:language"--> c21
end