User:Bouzinac/Recherches d'aéroports

From Wikidata
Jump to navigation Jump to search

Recherches sur une chaîne de texte

[edit]
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?airport ?airportLabel (SAMPLE(?coord) AS ?coord) ?ICAO ?IATA (SAMPLE(?Local_Code) AS ?Local_Code) WHERE {
  ?airport (wdt:P31/wdt:P279*) wd:Q62447.
  ?airport wdt:P17 wd:Q414.
  MINUS { ?airport wdt:P576 _:b2. }                                # remove items with P576 (dissolved, abolished or demolished) as a main property
  MINUS { ?airport wdt:P582 _:b3. }                                # remove items with P582 (end date) as a main property
#  MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q695850. }               # exclude military airports
  MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q1311670. }              # exclude railways stations
  MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q7373622. }              # exclude Royal Air Force
  MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q502074. }               # exclude héliports
  MINUS { ?airport wdt:P31/wdt:P279* wd:Q2265915.}                 # exclude vol à voile/gliders
  MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q44665966. }             # exclude  airports being build
  MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q782667. }               # exclude motorways where plane can land
  MINUS { ?airport a wdno:P17.}                                    # exclude airports that aren't physically based in a country
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,[AUTO_LANGUAGE]". }
  OPTIONAL { ?airport wdt:P625  ?coord. }
  OPTIONAL { ?airport wdt:P239  ?ICAO. }
  OPTIONAL { ?airport wdt:P238  ?IATA. }
  OPTIONAL { ?airport wdt:P240  ?Local_Code. }
  OPTIONAL { ?airport wdt:P5699 ?Local_Code. }
  OPTIONAL { ?airport wdt:P5746 ?Local_Code. }
  OPTIONAL { ?airport wdt:P5851 ?Local_Code. }
  OPTIONAL { ?airport wdt:P6120 ?Local_Code. }
FILTER(CONTAINS(LCASE(?airportLabel ), "keyword"))
}
GROUP BY ?airport ?airportLabel ?ICAO ?IATA
ORDER BY ?coord
Try it!

Look after a/some specific IATA code(s)

[edit]
SELECT distinct ?item ?itemLabel ?natureLabel WHERE {
{?item wdt:P238 ?IATA
VALUES ?IATA { "AMS" "BOO" }.} #item has a P238 value   
  OPTIONAL { ?item wdt:P31 ?nature. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . #this bit gets labels for Qid values
}
Try it!

Look after a/some specific Indian Railways code(s)

[edit]
SELECT distinct ?item ?itemLabel ?Indian ?natureLabel WHERE {
{?item wdt:P5696 ?Indian
VALUES ?Indian { "AMS" "BOO" }.} #item has a P5696 value   
  OPTIONAL { ?item wdt:P31 ?nature. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . #this bit gets labels for Qid values
}
Try it!

Look after a/some specific ICAO code(s)

[edit]
SELECT distinct ?item ?itemLabel ?natureLabel WHERE {
{?item wdt:P239 ?ICAO 
VALUES ?ICAO { "HKKG" }.} #item has a P239 value  
OPTIONAL { ?item wdt:P31 ?nature. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . #this bit gets labels for Qid values
}
Try it!

Look after a/some specific Code transport Canada code(s)

[edit]
SELECT distinct ?item ?itemLabel ?natureLabel WHERE {
{?item wdt:P5699 ?CodeTC 
VALUES ?CodeTC { "HKKG" }.} #item has a P5699 value  
OPTIONAL { ?item wdt:P31 ?nature. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . #this bit gets labels for Qid values
}
Try it!

Look after a/some specific FAA (USA) code(s)

[edit]
SELECT ?FAA_LID  ?item ?itemLabel (group_concat(?natureLabel) as ?natures) {
SELECT distinct ?FAA_LID ?item ?itemLabel ?nature ?natureLabel WHERE {
{?item wdt:P240 ?FAA_LID
VALUES ?FAA_LID {"AR44" "CO20" }.} #item has a P240 value   
OPTIONAL { ?item wdt:P31 ?nature. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" } . #this bit gets labels for Qid values
}
} group by ?FAA_LID ?item ?itemLabel
Try it!

Look after a/some specific Argentinean NCAA Airport code (P6120) code(s)

[edit]
SELECT ?FAA_LID  ?item ?itemLabel (group_concat(?natureLabel) as ?natures) {
SELECT distinct ?FAA_LID ?item ?itemLabel ?nature ?natureLabel WHERE {
{?item wdt:P6120 ?FAA_LID
VALUES ?FAA_LID {"AR44" "CO20" }.} #item has a P6120 value   
OPTIONAL { ?item wdt:P31 ?nature. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,es" } . #this bit gets labels for Qid values
}
} group by ?FAA_LID ?item ?itemLabel
Try it!

Look after a/some specific Ex-USSR internal airport code (P5851) code(s)

[edit]
SELECT ?Russian_LID ?item ?itemLabel (group_concat(?natureLabel) as ?natures) {
SELECT distinct ?Russian_LID ?item ?itemLabel ?nature ?natureLabel WHERE {
{?item wdt:P6120 ?Russian_LID 
VALUES ?Russian_LID {"AR44" "CO20" }.} #item has a P6120 value   
OPTIONAL { ?item wdt:P31 ?nature. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,ru" } . #this bit gets labels for Qid values
}
} group by ?Russian_LID ?item ?itemLabel
Try it!
SELECT ?DGAC_LID ?item ?itemLabel (group_concat(?natureLabel) as ?natures) {
SELECT distinct ?DGAC_LID ?item ?itemLabel ?nature ?natureLabel WHERE {
{?item wdt:P5746 ?DGAC_LID 
VALUES ?DGAC_LID {"AR44" "CO20" }.} #item has a P5746 value   
OPTIONAL { ?item wdt:P31 ?nature. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,es" } . #this bit gets labels for Qid values
}
} group by ?Russian_LID ?item ?itemLabel
Try it!

Check wiki airport element having neither IATA nor ICAO nor FAA LID

[edit]
SELECT DISTINCT ?airport ?airportlabel ?pays ?paysLabel WHERE {
  ?airport (wdt:P31/wdt:P279*) wd:Q62447.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr,de,kk". }
  FILTER(NOT EXISTS { ?airport wdt:P239| wdt:P238|wdt:P240| wdt:P5699| wdt:P5746| wdt:P5851|wdt:P6120 ?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 (wdt:P31/(wdt:P279*)) ?thing.
    VALUES ?thing {
      wd:Q695850      wd:Q2265915      wd:Q1311670      wd:Q7373622      wd:Q782667      wd:Q502074      wd:Q44665966      wd:Q2071567
      wd:Q3631092     wd:Q4930096 wd:Q3631092
    }
  } 
  ?airport wdt:P17 ?pays.
} order by ?paysLabel
Try it!

Look after a/some specific Indian Railways code(s)

[edit]
SELECT distinct ?item ?itemLabel ?Indian ?natureLabel WHERE {
{?item wdt:P5696 ?Indian
VALUES ?Indian { "AMS" "BOO" }.} #item has a P5696 value   
  OPTIONAL { ?item wdt:P31 ?nature. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . #this bit gets labels for Qid values
}
Try it!