query-00fdc413a44bf7ca074adc39b3cacee5
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 schema: <http://schema.org/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT distinct ?item ?itemLabel ?countryLabel ?fr_article ?Wfr ?en_article ?Wen ?iata ?icao WHERE {
?item wdt:P31/wdt:P279* wd:Q1248784. # item must be an instance of an airport, or an instance that is a subclass of an airport
optional {?item wdt:P17 ?country .} # ?item may have a country
optional {?item p:P238 ?node . # item may have a P238 (IATA) node
?node ps:P238 ?iata. # and the node has a P238 (IATA) value
filter not exists {?node pq:P582 [].} } # but the value is ignored if it has an end-date
optional {?item wdt:P239 ?icao .} # item may have a P239 (ICAO) value
optional {?Wen schema:about ?item; # item may have a sitelink
schema:isPartOf <https://en.wikipedia.org/>; # the sitelink points to en.wikipedia
schema:name ?en_article.} # and has an article name
optional {?Wfr schema:about ?item; # item may have a sitelink
schema:isPartOf <https://fr.wikipedia.org/>; # the sitelink points to fr.wikipedia
schema:name ?fr_article.} # and has an article name
minus {?item wdt:P31/wdt:P279* wd:Q695850.} # exclude items having instances that are military airports & subclasses thereof
bind(coalesce(?en_article,?fr_article) as ?article) # create ?article if there is an EN or FR wikipedia article
filter(bound(?article)) # select only if there is an ?article
bind(coalesce(?iata,?icao) as ?code) # create ?code if there is an ICAO or IATA code
# filter(bound(?code)) # select only if there is an ?code
minus {?item wdt:P576 [].} # remove items with P576 (dissolved, abolished or demolished) as a main property
minus {?item wdt:P582 [].} # remove items with P582 (end date) as a main property
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr" } . #this bit gets labels for Qid values
} order by ?countryLabel ?itemLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?Wen"):::projected
v11("?Wfr"):::projected
v13("?article")
v13("?code")
v6("?country")
v1("?countryLabel"):::projected
v10("?en_article"):::projected
v12("?fr_article"):::projected
v7("?iata"):::projected
v8("?icao"):::projected
v5("?item"):::projected
v2("?itemLabel"):::projected
v4("?node")
a1((" "))
a4((" "))
a5((" "))
a2((" "))
a3((" "))
c13([https://fr.wikipedia.org/]):::iri
c11([https://en.wikipedia.org/]):::iri
c4(["wd:Q1248784"]):::iri
c18(["bd:serviceParam"]):::iri
c20(["#91;AUTO_LANGUAGE#93;,fr"]):::literal
c14(["wd:Q695850"]):::iri
f0[["bound(?article)"]]
f0 --> v13
v5 --"p:direct/P31"--> a2
a2 --"p:direct/P279"--> c4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:direct/P17".-> v6
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:P238".-> v4
v4 --"p:statement/P238"--> v7
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:direct/P239".-> v8
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v9 -."schema:about".-> v5
v9 --"schema:isPartOf"--> c11
v9 --"schema:name"--> v10
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v11 -."schema:about".-> v5
v11 --"schema:isPartOf"--> c13
v11 --"schema:name"--> v12
end
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
v5 --"p:direct/P31"--> a3
a3 --"p:direct/P279"--> c14
end
bind2[/"?en_article?fr_article"/]
v10 --o bind2
v12 --o bind2
bind2 --as--o v13
bind3[/"?iata?icao"/]
v7 --o bind3
v8 --o bind3
bind3 --as--o v13
subgraph minus4["MINUS"]
style minus4 stroke-width:6px,fill:pink,stroke:red;
v5 --"p:direct/P576"--> a4
end
subgraph minus5["MINUS"]
style minus5 stroke-width:6px,fill:pink,stroke:red;
v5 --"p:direct/P582"--> a5
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c18 --"wikibase:language"--> c20
end