Module:Infobox/Ouvrage d'art

 Documentation[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 Ouvrage d'art.


local building = require "Module:Infobox/Fonctions/Bâtiment"
local bridge = require "Module:Infobox/Fonctions"
local localdata = require "Module:Infobox/Localdata"
local wd = require "Module:Wikidata"

local formats = {
	--{icône carte, icône entete, couleur titre, couleur sous-titre, couleur texte)
	Q1030403 = {'ferry', 'map', '#D4D0BA', '#D4D0BA', '#000000', 'defaut'}, -- pont-canal
	Q537127 = {'car', 'map', '#D4D0BA', '#D4D0BA', '#000000', 'defaut'}, -- pont routier
	Q1210334 = {'rail', 'map', '#D4D0BA', '#D4D0BA', '#000000', 'defaut'}, -- pont ferroviaire
	Q18615527 = {'rail-light', 'map', '#D4D0BA', '#D4D0BA', '#000000', 'defaut'}, -- pont tramway
	Q2502622 = {'bicycle', 'map', '#D4D0BA', '#D4D0BA', '#000000', 'defaut'}, -- pont cycliste
	default = {nil, 'map', '#D4D0BA', '#D4D0BA', '#000000', 'defaut'}
}

local function wdformat() --retourne une table contenant la couleur principale de l'infobox et l'icône de titre
	local wtypes = wd.stringTable{ -- récupère les Qid des professions
		entity = localdata.item,
		property = 'P31',
		displayformat = 'raw',
		excludespecial = true
	}
	local default = formats.default
	wtypes = wd.addVals(wtypes or {}, {property = 'P279'}, 1) -- on utilise en plus les sous-classe
	for i, item in pairs(wtypes or {}) do
		if formats[item] then
			return formats[item]
		end
	end
	return default
end
local function setcharte()
	local charte = localdata['charte']
	if charte then
		for i, j in pairs(formats) do
			if j[2] == charte then
				return j
			end
		end
	end
	return wdformat()
end

local displayformat = setcharte()

return 
	{
	maincolor = displayformat[3],
	secondcolor = displayformat[4],
	thirdcolor = displayformat[5],
	parts =
    	{
		bridge.title(displayformat[2], nil, 'nom local', nil),
		bridge.mainimage('Article à illustrer Pont', 'Defaut 2.svg'),
		{type = 'table', rows = {
			{type = 'row', label = 'Nom local', value = {'nom local', 'nom dans la langue originale'}, wikidata = {property = 'P1705', showlang = true}},
			{type = 'row', label = 'Nom officiel', plurallabel = 'Noms officiels', value = 'nom officiel', wikidata = {property = 'P1448', showlang = true}},
		}},
		{type = 'table', title = 'Géographie', rows = {
			building.mountainrange(),
			{type = 'row', label = 'Site', plurallabel = 'Sites', value = 'site', property = 'P706'},
			building.country(),
			building.historicalregion(),
			building.adminlocation(),
			building.protectedarea(),
			building.coordinates(),
			},
		},
		{type = 'table', title = 'Caractéristiques techniques', rows = {
			{type = 'row', label = 'Type', value = 'type', wikidata = {property = 'P31', defaultlinkquery = 'P279', targetvalue = {'Q12570', 'Q158218', 'Q158438', 'Q158555', 'Q158626', 'Q653401', 'Q818882', 'Q911663', 'Q950431', 'Q1055465', 'Q1429218', 'Q1735471', 'Q5592057', 'Q7577756', 'Q14276458', 'Q109419780'}}},
			{type = 'row', label = 'Longueur', value = 'longueur', wikidata = {property = 'P2043', targetunit = 'm', rounding = '1'}},
			{type = 'row', label = 'Travées', value = 'travées', property = 'P1314'},
			{type = 'row', label = 'Portée', value = 'portée', wikidata = {property = 'P2787', targetunit = 'm', rounding = '1'}},
			{type = 'row', label = 'Largeur', value = 'largeur', wikidata = {property = 'P2049', targetunit = 'm', rounding = '1'}},
			building.elevation(),
			{type = 'row', label = 'Hauteur', value = 'hauteur', wikidata = {property = 'P2048', targetunit = 'm', rounding = '1'}},
			{type = 'row', label = 'Hauteur libre', value = 'hauteur libre', wikidata = {property = 'P2793', targetunit = 'm', rounding = '1'}},
			building.material(),
			building.colour(),
			building.archistyle(),
			},
		},
		{type = 'table', title = 'Fonction', rows = {
			{type = 'row', label = 'Fonction', plurallabel = 'Fonctions', value = 'fonction', wikidata = {property = 'P31', showdate = 'yes', targetvalue = {'Q537127', 'Q1030403', 'Q1068842', 'Q1210334', 'Q1311958', 'Q2354973', 'Q4291972', 'Q6636777', 'Q14500296', 'Q18615527', 'Q108893042', 'Q109274653'}}},
			{type = 'row', label = 'Itinéraire', plurallabel = 'Itinéraires', value = 'itinéraire', wikidata = {property = 'P2505', showqualifiers = 'P560', showdate = 'true'}},
			{type = 'row', label = 'Franchit', value = 'franchit', property = 'P177'},
			{type = 'row', label = 'En aval de', value = 'en aval de', property = 'P2673'},
			{type = 'row', label = 'En amont de', value = 'en amont de', property = 'P2674'},
			{type = 'row', label = 'Vitesse limitée à', value = 'vitesse', property = 'P3086'},
			},
		},
		{type = 'table', title = 'Historique', rows = {
			{type = 'row', label = 'Anciens noms', value = 'noms'},
			building.creator(),
			{type = 'row', label = 'Maître d\'œuvre', plurallabel = 'Maîtres d\'œuvre', value = 'maître d\'oeuvre', property = 'P193'},
			{type = 'row', label = 'Maître d\'ouvrage', plurallabel = 'Maîtres d\'ouvrage', value = 'maître d\'ouvrage'},
			{type = 'row', label = 'Entreprises', value = 'entreprises'},
			building.construction(),
			building.awards(),
			building.opening(),
			building.renovation(),
			{type = 'row', label = 'Reconversion', value = 'reconversion'},
			building.closure(),
			building.demolition(),
			building.destroyedby(),
			building.protection(),
			},
		},
		{type = 'table', title = 'Référents', rows = {
			building.owner(),
			{type = 'row', label = 'Concessionnaire', plurallabel = 'Concessionnaires', value = 'concessionnaire', property = 'P137'},
			building.maintenance(),
			{type = 'row', label = '[[National Bridge Inventory|NBI]]', value = 'NBI', property = "P3676"},
			{type = 'row', label = 'Bridgehunter', value = 'Bridgehunter', wikidata = {property = "P1381", urlpattern="http://www.bridgehunter.com/$1"}},
			{type = 'row', label = 'BridgeReports', value = 'BridgeReports', wikidata = {property = "P1380", urlpattern="http://bridgereports.com/$1"}},
			{type = 'row', label = 'Brueckenweb', value = 'Brueckenweb', wikidata = {property = "P4328", urlpattern="https://www.brueckenweb.de/2content/datenbank/bruecken/3brueckenblatt.php?bas=$1"}},
			{type = 'row', label = '[[Département des Transports du Minnesota|Historic Bridges]]', value = 'Historic Bridges', wikidata = {property = "P8650", urlpattern="https://www.dot.state.mn.us/historicbridges/$1.html"}},
			{type = 'row', label = 'Lostbridges', value = 'Lostbridges', wikidata = {property = "P1311", urlpattern="http://www.lostbridges.org/details.aspx?id=$1"}},
			},
		},
		building.geoloc({marker=displayformat[1], default_zoom=13}),
	}
}