Module:Infobox/Aéroport
Apparence
[voir] [modifier] [historique] [purger]
Cette page définit un module d'infobox. Pour les conseils sur l'usage de ce module, voyez Modèle:Infobox Aéroport.
La documentation de ce module est générée par le modèle {{Documentation module}}.
Elle est incluse depuis la page Modèle:Documentation module d'infobox. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local building = require "Module:Infobox/Fonctions/Bâtiment"
local general = require "Module:Infobox/Fonctions"
local wikidata = require "Module:Wikidata"
local linguistic = require "Module:Linguistique"
local convert = require 'Module:Conversion'._convert
local makelink = require 'Module:Weblink'.makelink
local function displayLength(lengthM, lengthFt)
if (not lengthM and not lengthFt) then
return nil
end
local function toFeet(lengthM) return convert(lengthM, 'metre', 'foot', 0, 'with unit') end
local function toMetre(lengthFt) return convert(lengthFt, 'foot', 'metre', 0, 'with unit') end
if lengthM then
if not legnthFt then
local success, val = pcall(toFeet, lengthM)
if success then lengthFt = val end
end
lengthM = lengthM .. ' m'
else
if not legnthM then
local success, val = pcall(toMetre, lengthFt)
if success then lengthM = val end
end
lengthFt = lengthFt .. ' ft'
end
return lengthM .. (linguistic.inparentheses(lengthFt) or '')
end
local runwayheader = mw.html.create('tr')
:tag('th'):wikitext('Direction'):done()
:tag('th'):wikitext('Longueur'):done()
:tag('th'):wikitext('Surface'):done()
:done()
local helisurfaceheader = mw.html.create('tr')
:tag('th'):css{ width = '700px', ['margin-left'] = 'auto', ['margin-right'] = 'auto'}:wikitext('Numéro'):done()
:tag('th'):wikitext('Longueur')
:tag('th'):wikitext('Surface')
:done()
local function getDate(event)
return wikidata.getTheDate{targetvalue = event, property = 'P793', addcat = true, entity = item}
end
local function runwayrow(direction, surface, lengthM, lengthFt)
if not (direction or surface or lengthM or lengthFt) then
return nil
end
local length = displayLength(lengthM, lengthFt)
local row = mw.html.create('tr')
:tag('td'):wikitext(direction or '<i>à renseigner</i>'):done()
:tag('td'):wikitext(length or '<i>à renseigner</i>'):done()
:tag('td'):wikitext(surface or '<i>à renseigner</i>'):done()
:done()
return row
end
local function maplink(zone, oaci)
--[[[http://www.sia.aviation-civile.gouv.fr/aip/enligne/PDF_AIPparSSection/{{Modèle:Infobox Aéroport/SIA|{{{OACI|}}}|VAC}}/AD/2/{{#time:ym|+1 month}}_AD-2.{{{OACI}}}.pdf VAC] {{#if: {{Modèle:Infobox Aéroport/SIA|{{{OACI|}}}|IAC}}| - [http://www.sia.aviation-civile.gouv.fr/aip/enligne/PDF_AIPparSSection/{{Modèle:Infobox Aéroport/SIA|{{{OACI|}}}|IAC}}/AD/2/{{#time:ym|+1 month}}_AD-2.{{{OACI}}}.pdf IAC]}} {{#if: {{Modèle:Infobox Aéroport/SIA|{{{OACI|}}}|ARRDEP}}| - [http://www.sia.aviation-civile.gouv.fr/aip/enligne/PDF_AIPparSSection/{{Modèle:Infobox Aéroport/SIA|{{{OACI|}}}|ARRDEP}}/AD/2/{{#time:ym|+1 month}}_AD-2.{{{OACI}}}.pdf ARR/DEP]}}]]--
if zone == 'france' or zone == 'q142' then -- TODO utiliser module:Counry data pour faire plus propre
local link
end
return
end
return
{
maincolor = '#98aec8',
parts =
{
{
type = 'title',
value = 'nom',
subtitle = function(localdata)
local name1, name2 = localdata['nom_po'], localdata['nom_pa'] -- noms de paramètres à harmoniser avec les autres modèles
if nam1 or name2 then
return linguistic.conj({name1, name2}, '<br />')
end
end
},
-- ajouter ? general.logo(),
building.mainimage(),
{type = 'images', size = '100px', parameters = {'cocarde', 'cocarde2'}},
{type = 'table', title = 'Localisation', rows = {
building.country(),
{type = 'row', value = 'division', label = function(localdata) return localdata['nom de division'] or 'Division' end},
{type = 'row', value = 'division 2', label = function(localdata) return localdata['nom de division 2'] or 'Division' end},
{type = 'row', value = 'ville', label = 'Ville'},
{type = 'row', label = 'Date d’ouverture', value = 'ouverture',
wikidata = function(item) return getDate('Q18123869') end
},
{type = 'row', label = 'Date d’ouverture', value = 'ouverture',
wikidata = function(item) return getDate('Q14954904') end
},
{type = 'row', label = 'Superficie', value = 'superficie'},
{type = 'row', label = 'Altitude', value = function(localdata)
return displayLength( localdata['altitude m'], localdata['altitude ft'])
end
},
building.coordinates('Aéroport sans toponyme'), -- afficher l'avion dans le sens des pistes ?
},
},
-- liste des pistes
{type = 'table', title = 'Pistes', rows = {
{
type = 'text',
value =
function(localdata)
local tab = mw.html.create('table')
:css{ display = 'block', ['margin-left'] = 'auto', ['margin-right'] = 'auto', ['background-color'] = '#98aec8', ['text-align'] = "center", padding = '5px', ['line-height'] = "13px"}
:node(runwayheader)
local hasrows = false
for i = 1, 10 do
local row = runwayrow(localdata['direction piste'..tostring(i)], localdata['revetement piste'..tostring(i)], localdata['longueur piste'..tostring(i) .. ' m'], localdata['longueur piste'.. tostring(i) .. ' ft'])
if row then
tab:node(row)
hasrows = true
end
end
tab:allDone()
if hasrows then
return tostring(tab)
end
end
},
}},
-- liste des hélisurfaces
{type = 'table', title = 'Hélisurfaces', rows = {
{
type = 'text',
value =
function(localdata)
local tab = mw.html.create('table')
:css{['background-color'] = '#98aec8', ['text-align'] = "center", padding = '3px', ['line-height'] = "13px"}
:node(runwayheader)
local hasrows = false
for i = 1, 10 do
local row = runwayrow(localdata['numero helisurface'..tostring(i)], localdata['revetement helisurface'..tostring(i)], localdata['longueur helisurface'..tostring(i) .. ' m'], localdata['longueur helisurface'.. tostring(i) .. ' ft'])
if row then
tab:node(row)
hasrows = true
end
end
tab:allDone()
if hasrows then
return tostring(tab)
end
end
},
}},
{type = 'table', title = 'Informations aéronautiques', rows = {
{type = 'row', label = '[[code AITA]]', value = 'AITA', property = 'P238'},
{type = 'row', label = '[[code OACI]]', value = 'OACI', property = 'P239'},
{type = 'row', label = 'Nom cartographique', value = 'nom carto'},
{type = 'row', label = 'Type d’aéroport', value = 'type'},
{type = 'row', label = 'Gestionnaire', value = 'gestionnaire', property = 'P137'},
{type = 'row', label = 'Site web gestionnaire', value =
function(localdata)
local url = localdata['site web gestion']
return makelink(url, 'consulter')
end
},
{type = 'row', label = 'Site web aéroport', value =
function(localdata)
local url = localdata['site web aéro']
return makelink(url, 'consulter')
end
},
-- todo : liens cartos
{type = 'row', label = 'Cartes [[Service de l\'information aéronautique|SIA]]', value =
function(localdata, item)
local country = localdata['pays'] or wikidata.formatStatments{entity = item, property = 'P17', displayformat = 'raw'}
return maplink (country)
end
}
}
},
building.geoloc(),
}
}