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
lengthFt = toFeet(lengthM)
lengthM = lengthM .. ' m'
else
lengthM = toMetre(lengthFt)
lengthFt = lengthFt .. ' ft'
end
return lengthM .. linguistic.inparentheses(lengthFt)
end
local runwayheader = mw.html.create('tr')
:tag('th')
:wikitext('Direction')
:tag('th')
:wikitext('Longueur')
:tag('th')
:wikitext('Surface')
:done()
local helisurfaceheader = mw.html.create('tr')
:tag('th')
:wikitext('Numéro')
: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)
:tag('td'):wikitext(length)
:tag('td'):wikitext(surface)
end
local function helisurfacerow(number, surface, lengthM, lengthFt)
if not (number or surface or lengthM or lengthFt) then
return nil
end
local length = displayLength(lengthM, lengthFt)
local row = mw.html.create('tr')
:tag('td'):wikitext(number)
:tag('td'):wikitext(length)
:tag('td'):wikitext(surface)
end
return
{
maincolor = '#FFFFFF',
parts =
{
--[[ todo : titre
{
type = 'title',
text = localdata['nom']
subtext = function(localdata)
local name1, name2 = localdata['nom_po'], localdata['nom_pa']
if not (name1 or name2) then
return nil
end
local str = ''
if c
if localdata po
]]--
-- 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 = 'row',
value =
function(localdata)
local tab = runwayheader
for i = 1, 10 do
local row = runwayrow(localdata['direction piste '..tostring(i)], localdata['longueur piste '..tostring(i)], localdata['revetement piste '..tostring(i)])
if row then
tab:node(row)
end
end
if tab ~= runwayheader then
return tab
end
end
},
-- liste des hélisurfaces
{
type = 'row',
value =
function(localdata)
local tab = helisurfaceheader
for i = 1, 10 do
local row = runwayrow(localdata['numero helisurface '..tostring(i)], localdata['longueur helisurface '..tostring(i)], localdata['revetement helisurface '..tostring(i)])
if row then
tab:node(row)
end
end
if tab ~= helisurfaceheader then
return 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'}
if not country or (mw.ustring.lower(country) ~= 'france' and country ~= 'Q142') then-- TODO utiliser module:Drapeau pour faire plus propre
return nil
end
end
}
}
}
}
}