query-39a342fd5029ed076e685aa4493a8173

rq turtle/ttl

TODO

Use at

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 bd: <http://www.bigdata.com/rdf#>
SELECT distinct ?item ?itemLabel ?countryLabel ?iata ?icao 



where {
  { {select ?item 
WHERE {
  ?item wdt:P31 wd:Q1248784.
  OPTIONAL { ?item wdt:P238 ?iata. }
  OPTIONAL { ?item wdt:P239 ?icao. }
  filter(bound(?iata)|| bound(?icao))
  } }.} union {   {select ?item 
where {
  ?item wdt:P31 wd:Q695850.
  minus {?item wdt:P31 wd:Q1248784.}
  OPTIONAL { ?item wdt:P238 ?iata. }
  OPTIONAL { ?item wdt:P239 ?icao. }
  filter not exists {?iata ^wdt:P238 ?item2. ?item2 wdt:P31 wd:Q1248784}
  filter not exists {?icao ^wdt:P239 ?item2. ?item2 wdt:P31 wd:Q1248784}
  filter(bound(?iata) || bound(?icao))
  } }.}
  OPTIONAL { ?item wdt:P238 ?iata. }
  OPTIONAL { ?item wdt:P239 ?icao. }
  OPTIONAL { ?item wdt:P17 ?country. }
  MINUS    { ?item wdt:P576 [].}                    # remove items with P576 (dissolved, abolished or demolished) as a main property
  MINUS    { ?item (wdt:P31/wdt:P279*) wd:Q782667. } # exclude motorways where plane can land
  MINUS    { ?item wdt:P31/wdt:P279* wd:Q44665966.} # exclude  airports being build
  MINUS    { ?item wdt:P31/wdt:P279* wd:Q2265915.}  # exclude vol à voile
  MINUS    {?item wdt:P582 [].}                    # remove items with P582 (end date) as a main property
  MINUS    { ?item a wdno:P17.}                    #exclude airports that aren't physically based in a country
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en". }
}
ORDER BY ?countryLabel ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?country") v1("?countryLabel"):::projected v3("?iata"):::projected v4("?icao"):::projected v5("?item"):::projected v6("?item2") v2("?itemLabel"):::projected a1((" ")) a5((" ")) a2((" ")) a3((" ")) a4((" ")) c11(["wd:Q2265915"]):::iri c9(["wd:Q782667"]):::iri c14(["wdno:P17"]):::iri c2(["wd:Q1248784"]):::iri c16(["bd:serviceParam"]):::iri c5(["wd:Q695850"]):::iri c18(["fr,en"]):::literal c10(["wd:Q44665966"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; f0[["(bound(?iata) || bound(?icao))"]] f0 --> v3 f0 --> v4 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 --"wdt:P239"--> e0v2 e0v1 --"wdt:P31"--> e0c3 e0v2("?icao"):::projected e0v1("?item2"):::projected e0c3(["wd:Q1248784"]):::iri end f1--EXISTS--> f1e0 f1 --> v6 f1 --> c4 f1 --> v4 f1 --> c1 f1 --> c2 v6 --"wdt:P239"--> v4 v6 --"wdt:P31"--> c2 f2[["not "]] subgraph f2e1["Exists Clause"] e1v1 --"wdt:P238"--> e1v2 e1v1 --"wdt:P31"--> e1c3 e1v2("?iata"):::projected e1v1("?item2"):::projected e1c3(["wd:Q1248784"]):::iri end f2--EXISTS--> f2e1 f2 --> v6 f2 --> c3 f2 --> v3 f2 --> c1 f2 --> c2 v6 --"wdt:P238"--> v3 v6 --"wdt:P31"--> c2 v5 --"wdt:P31"--> c5 subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v5 --"wdt:P31"--> c2 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P238".-> v3 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P239".-> v4 end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f4[["(bound(?iata) || bound(?icao))"]] f4 --> v3 f4 --> v4 v5 --"wdt:P31"--> c2 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P238".-> v3 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P239".-> v4 end end union0r <== or ==> union0l end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P238".-> v3 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P239".-> v4 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P17".-> v7 end subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; v5 --"wdt:P576"--> a1 end subgraph minus6["MINUS"] style minus6 stroke-width:6px,fill:pink,stroke:red; v5 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c9 end subgraph minus7["MINUS"] style minus7 stroke-width:6px,fill:pink,stroke:red; v5 --"wdt:P31"--> a3 a3 --"wdt:P279"--> c10 end subgraph minus8["MINUS"] style minus8 stroke-width:6px,fill:pink,stroke:red; v5 --"wdt:P31"--> a4 a4 --"wdt:P279"--> c11 end subgraph minus9["MINUS"] style minus9 stroke-width:6px,fill:pink,stroke:red; v5 --"wdt:P582"--> a5 end subgraph minus10["MINUS"] style minus10 stroke-width:6px,fill:pink,stroke:red; v5 --"a"--> c14 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c16 --"wikibase:language"--> c18 end