Module:Infobox/Route
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 Route.
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 localdata = require 'Module:Infobox/Localdata'
local general = require 'Module:Infobox/Fonctions'
local wikidata = require 'Module:Interface Wikidata'.fromLua
local linguistic = require 'Module:Linguistique'
local function DivisionsAdministratives()
if not localdata.item then
return nil
end
-- on cherche le pays pour être sûr de s'arrêter avant
local country = wikidata.stringTable{entity = localdata.item, property = 'P17', displayformat = 'raw'}
local countryid
if country then
countryid = country[1]
end
-- récupération des valeurs
local list = wikidata.transitiveVals(localdata.item, {property = 'P131', atdate = 'today'}, 3, 30, countryid)
if not list then
return nil
end
-- création des colonnes
local rows = {}
for i, div in pairs(list) do
if (div == countryid) then
break
end
local label = wikidata.formatStatements{
entity = div,
property = 'P31',
defaultlinkquery = {property = 'P2354'},-- si pas de lien, lier vers la page de liste e.g liste des Etats de Califorie
defaultlink = '-', -- si aucun lien Wikipédia, pas de lien Wikidata
labelformat = function(id)
local str = wikidata.getLabel(id)
if str then
return linguistic.removecomplement(str)
else
return ''
end
end
}
local val = wikidata.formatEntity(div)
table.insert(rows, 1, {type = 'row', label = label, value = function() return val end})
end
return rows
end
--- par Wikidata
local function wikidataDivRows() -- liste de lignes de divisions administrative basée sur des données de Wikidata
if not localdata.item then
return nil
end
-- on cherche le pays pour être sûr de s'arrêter avant
local country = wikidata.stringTable{entity = localdata.item, property = 'P17', displayformat = 'raw'}
local countryid
if country then
countryid = country[1]
end
-- récupération des valeurs
local list = wikidata.transitiveVals(localdata.item, {property = 'P131', atdate = 'today'}, 3, 5, countryid)
if not list then
return nil
end
-- création des colonnes
local rows = {}
for i, div in pairs(list) do
if (div == countryid) then
break
end
local label = wikidata.formatStatements{
entity = div,
property = 'P31',
numval = 1,
defaultlinkquery = {property = 'P2354'},-- si pas de lien, lier vers la page de liste e.g liste des Etats de Califorie
defaultlink = '-', -- si aucun lien Wikipédia, pas de lien Wikidata
labelformat = function(id)
local str = wikidata.getLabel(id)
if str then
return linguistic.removecomplement(str)
else
return ''
end
end
}
local val = wikidata.formatEntity(div)
table.insert(rows, 1, {type = 'row', label = label, value = function() return val end})
end
return rows
end
return
{
maincolor = '#CCCCCC',
parts =
{
-- Titre
{
type = 'title',
value = function()
return localdata['numéro de route']
or wikidata.formatStatements{entity = localdata.item, property = 'P1824', conjtype = ' / '}
or wikidata.getLabel(id)
end,
subtitle = function()
local localname = localdata['nom']
if not localname then
return nil
end
localname = '<i>' .. localname .. '</i>'
local lang = localdata['code langue']
lang = require 'Module:Langue'.indicationDeLangue{nil, lang}
return linguistic.conj({lang, localname}, ' ')
end,
wikidatasubtitle = function()
local data = wikidata.formatAndCat({entity = localdata.item, property = 'P1705', conjtype = 'new line', showlang = true})
if (data == nil) or (data == "") then
return nil
else
return '<i>' .. data .. '</i>'
end
end,
icon = 'route'
},
-- Cartouche signalétique
{
type = 'images',
defaultsize = 'x50px',
defaultalt = 'Cartouche signalétique représentant la route',
wikidata = {property = 'P14'},
numval = 5,
style = {padding = '0 0 6px 0'}
},
general.mainimage(),
-- Carte de localisation
{
type = 'images',
imageparameters = 'carte',
sizeparameter = 'taille carte',
captionparameter = 'légende carte',
wikidata = {property = 'P15'},
numval = 1
},
-- Tableau sans titre
{
type = 'table',
rows = {
{type = 'mixed', label = 'Autre nom', plurallabel = 'Autres noms', valeur = 'autres noms', wikidata = {property = 'P1449', showlang = true, conjtype = 'new line'} },
{type = 'mixed', label = 'Historique', wikidata = {property = 'P793', showdate = true, sorttype = 'chronological', conjtype = 'new line'} }
}
},
-- Tableau des caractéristiques
{
type = 'table',
title = 'Caractéristiques',
rows = {
{type = 'mixed', label = 'Longueur', value = 'longueur', wikidata = {property = 'P2043', targetunit = 'kilometre', rounding = 1} },
{
type = 'mixed',
label = 'Direction',
value = function(localdata)
local dir = localdata['direction'] or wikidata.formatStatements{entity = localdata.item, property = {'P559', 'P609'}, showonlyqualifier = 'P560', conjtype = '/', link = '-', removedupes = true}
if (dir == nil) or (dir == "") then
return nil
end
return dir
end
},
{type = 'mixed', label = 'Extrémités', value = 'itinéraire', wikidata = {property = 'P559', showqualifiers = 'P609', conjtype = ' – ', labelformat = function(id) return wikidata.formatStatements{entity = id, property = 'P1824', numval = 1} or wikidata.getLabel(id) end} },
{type = 'mixed', label = '[[Ceinture périphérique]]', value = 'ceinture péripherique' },
{type = 'mixed', label = 'Réseau', plurallabel = 'Réseaux', value = 'réseau', wikidata = {property = 'P16', defaultlinkquery = {property = 'P2354'}} },
{type = 'mixed', label = 'Autre classement', plurallabel = 'Autres classements', value = 'autres classements', wikidata = {property = {'P361', 'P1382'}, excludespecial = true, labelformat = function(id) return wikidata.formatStatements{entity = id, property = 'P1824', numval = 1} or wikidata.getLabel(id) end} },
{type = 'mixed', label = 'Exploitant', plurallabel = 'Exploitants', value = 'exploitant', wikidata = {property = 'P137', conjtype = 'new line'} },
{type = 'mixed', label = 'Gestionnaire', plurallabel = 'Gestionnaires', value = 'gestionnaire', wikidata = {property = 'P126', conjtype = 'new line'} }
}
},
-- Territoires traversés
{
type = 'table',
title = 'Territoires traversés',
rows = {
general.country(),
--{type = 'multi', rows = wikidataDivRows() or {} },
{type = 'multi', rows = DivisionsAdministratives() or {} },
{type = 'mixed', label = 'Ville principale', plurallabel = 'Villes principales', value = 'villes principales', property = 'P1302' },
}
},
-- Tableau sur le parcours
{
type = 'table',
title = 'Intersections',
rows = {
--{type = 'row', value = 'intersections', wikidata = {property = 'P2789', showqualifiers = 'P131', conjtype = 'new line', labelformat = function(id) return wikidata.formatStatements{entity = id, property = 'P1824', numval = 1} or wikidata.getLabel(id) end} }
{type = 'row', value = 'intersections', wikidata = function()
local data = wikidata.formatAndCat({entity = localdata.item, property = 'P2789', showqualifiers = 'P131', conjtype = 'new line', labelformat = function(id) return wikidata.formatStatements{entity = id, property = 'P1824', numval = 1} or wikidata.getLabel(id) end})
if (data == nil) or (data == "") then
return nil
else
return "<div class='NavFrame' style='border:none; padding:0'><div class='NavHead' style='background-color:" .. maincolor .. "; padding:1px; text-align:left;' /><div class='NavContent' style='text-align:left; margin-top:-5px; margin-left:1em; margin-bottom:4px;'>" .. data .. '</div></div>'
end
end}
}
}
}
}