Module:Infobox/Barrage

Une page de Wikipédia, l'encyclopédie libre.

 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 Barrage.


local general = require "Module:Infobox/Fonctions"
local localdata = require "Module:Infobox/Localdata"
local wikidata = require "Module:Wikidata"
local unit = require "Module:Unité"
local power = require "Module:Infobox/Fonctions/Centrale électrique"

local function coord_centrale(lon, lat)
	if lon and lat then
		return general.coordinates({longitude=lon, latitude=lat})
	end
end
	
local reservoir = wikidata.stringTable{entity = localdata.item, property = 'P4661', displayformat = 'raw'}
local reservoirid = ''
if reservoir then
	reservoirid = reservoir[1]
end
local point = 'barrage'
if (localdata[ 'orientation' ] == 'n' or localdata[ 'orientation' ] == 's' or localdata[ 'orientation' ] == 'e' or localdata[ 'orientation' ] == 'o' or localdata[ 'orientation' ] == 'ne' or localdata[ 'orientation' ] == 'no' or localdata[ 'orientation' ] == 'se' or localdata[ 'orientation' ] == 'so') then
	point = 'barrage ' .. localdata[ 'orientation' ]
elseif (localdata[ 'orientation' ] == 'w') then
	point = 'barrage o'
elseif (localdata[ 'orientation' ] == 'nw') then
	point = 'barrage no'
elseif (localdata[ 'orientation' ] == 'sw') then
	point = 'barrage so'
end

return {
	maincolor = '#87CEEB',
	parts = {
		general.title('defaut', {}, 'nom 2'),
		general.mainimage('Article à illustrer Barrage'),
		{type = 'table', title = 'Géographie', rows = {
			power.adminlocation(),
			{type = 'row', label = 'Nom (en langue locale)', value = 'nom_po', property = 'P1705'},
			general.coordinates(),
			{type = 'row', label = "Cours d'eau", value = 'cours_eau'},
		}},
		{type = 'table', title = 'Objectifs et impacts', rows = {
			{
				type = 'row',
				label = 'Vocation',
				value = 'vocation',
				wikidata = {property = 'P366', conjtype='new line'}
			},
			{type = 'row',
					label = 'Propriétaire',
					plurallabel = 'Propriétaires',
					value = 'propriétaire',
					wikidata = {property = 'P127', atdate = "today", showdate = true, sorttype = 'inverted', precision = 'year', showqualifiers = "P1107", qualiftargetunit = 'percent'}},
			power.operateur(),
			{type = 'row', label = 'Conception', value = 'concepteur'},
			{type = 'row', label = 'Date du début des travaux', value = 'début_travaux', property = 'P571'},
			{type = 'row', label = 'Date de la fin des travaux', value = 'fin_travaux'},
			{type = 'row', label = 'Date de mise en service', value = 'mise_en_service', property = 'P729'},
			{type = 'row', label = 'Coût', value = 'coût', property = 'P2130'},
			{type = 'row', label = 'Statut', value = 'statut', wikidata = {property = 'P5817', defaultlink = '-'}},
			{type = 'row', label = 'Classement', value = 'classement'},
		}},
		{type = 'table', title = 'Barrage', rows = {
			{
				type = 'row', 
				label = 'Type', 
				value = 'type',
				wikidata = {property = 'P31', conjtype='new line', targetvalue = {'Q3497167','Q1244922','Q890545','Q357679','Q53726656','Q1355334','Q105190'}} --poids, en remblais, voûte, poids-voûte, multi-voûte, à contreforts, digue
			},
			{
				type = 'row',
				label = 'Hauteur<br /><small>(lit de rivière)</small>',
				value = function ( localdata )
					if localdata[ 'hauteur_barrage' ] then
						return unit._unite{localdata[ 'hauteur_barrage' ],'[[Mètre|m]]'}
					end
				end,
			},
			{
				type = 'row',
				label = 'Hauteur<br /><small>(fondation)</small>',
				value = function ( localdata )
					if localdata[ 'hauteur_barrage_fondation' ] then
						return unit._unite{localdata[ 'hauteur_barrage_fondation' ],'[[Mètre|m]]'}
					end
				end,
			},
			{
				type = 'row', 
				label = 'Longueur', 
				value = function ( localdata )
					if localdata[ 'longueur_barrage' ] then  
						return unit._unite{localdata[ 'longueur_barrage' ],'[[Mètre|m]]'}
					end
				end, 
				wikidata = {property = 'P2043', showlink = true}
			},
			{
				type = 'row', 
				label = 'Épaisseur en crête', 
				value = function ( localdata )
					if localdata[ 'épaisseur_barrage_sommet' ] then
						return unit._unite{localdata[ 'épaisseur_barrage_sommet' ],'[[Mètre|m]]'}
					end
				end,
				wikidata = {property = 'P2049', qualifier = 'P518' , qualifiervalue = 'Q56099012', showlink = true} --largeur s'applique à dam crest
			},
			{
				type = 'row', 
				label = 'Épaisseur à la base', 
				value = function ( localdata )
					if localdata[ 'épaisseur_barrage_base' ] then
						return unit._unite{localdata[ 'épaisseur_barrage_base' ],'[[Mètre|m]]'}
					end
				end,
				wikidata = {property = 'P2049', qualifier = 'P518' , qualifiervalue = 'Q56425045', showlink = true} --largeur s'applique à level of foundation
			},
			{
				type = 'row', 
				label = 'Altitude de la crête', 
				value = function ( localdata )
					if localdata[ 'altitude_crête' ] then
						return unit._unite{localdata[ 'altitude_crête' ],'[[Mètre|m]]'}
					end
				end, 
				wikidata = {property = 'P2044', qualifier = 'P518' , qualifiervalue = 'Q56099012', showlink = true} --altitude s'applique à dam crest
			},
	 {
				type = 'row', 
				label = 'Volume du barrage', 
				value = function ( localdata )
					if tonumber(localdata[ 'volume_barrage' ]) then
						if tonumber(localdata[ 'volume_barrage' ]) >= 2000000 then
							return unit._unite{tonumber(localdata[ 'volume_barrage' ])/1000000, 'millions de [[Mètre cube|m³]]'}
						elseif tonumber(localdata[ 'volume_barrage' ]) >= 1000000 and tonumber(localdata[ 'volume_barrage' ]) < 2000000 then
							return unit._unite{tonumber(localdata[ 'volume_barrage' ])/1000000, 'million de [[Mètre cube|m³]]'}
						else
							return unit._unite{localdata[ 'volume_barrage' ], '[[Mètre cube|m³]]'}
                		end
					end
				end,
			},
		}},
		{type = 'table', title = 'Réservoir', rows = {
			{type = 'row', label = 'Nom', value = 'réservoir', property = 'P4661'},
			{
				type = 'row', 
				label = 'Altitude', 
				value = function ( localdata )
					if localdata[ 'altitude_réservoir' ] then
						return unit._unite{localdata[ 'altitude_réservoir' ],'[[Mètre|m]]'}
					end
				end,
				wikidata = {entity = reservoirid, property = 'P2044', showlink = true, condition = function() return reservoirid end}
			},
			{
				type = 'row', 
				label = 'Altitude maximale', 
				value = function ( localdata )
					if localdata[ 'altitude_max_réservoir' ] then
						return unit._unite{localdata[ 'altitude_max_réservoir' ],'[[Mètre|m]]'}
					end
				end,
			},
			{
				type = 'row', 
				label = 'Altitude normale', 
				value = function ( localdata )
					if localdata[ 'altitude_norm_réservoir' ] then
						return unit._unite{localdata[ 'altitude_norm_réservoir' ],'[[Mètre|m]]'}
					end
				end,
			},
			{
				type = 'row', 
				label = 'Volume', 
				value = function ( localdata )
					if tonumber(localdata[ 'volume_réservoir' ]) then
						if tonumber(localdata[ 'volume_réservoir' ]) >= 1000 then
							return unit._unite{tonumber(localdata[ 'volume_réservoir' ])/1000, '[[Mètre cube|km³]]'}
						elseif tonumber(localdata[ 'volume_réservoir' ]) >= 2 then
							return unit._unite{localdata[ 'volume_réservoir' ], 'millions de [[Mètre cube|m³]]'}
						else
							return unit._unite{localdata[ 'volume_réservoir' ], 'million de [[Mètre cube|m³]]'}
						end
					end
				end,
				wikidata = {entity = reservoirid, property = 'P2234', targetunit = 'million cubic metre', shomwunit = long, showlink = false, condition = function() return reservoirid end}
			},
			{
				type = 'row', 
				label = 'Volume maximal', 
				value = function ( localdata )
					if tonumber(localdata[ 'volume_max_réservoir' ]) then
						if tonumber(localdata[ 'volume_max_réservoir' ]) >= 1000 then
							return unit._unite{tonumber(localdata[ 'volume_max_réservoir' ])/1000, '[[Mètre cube|km³]]'}
						elseif tonumber(localdata[ 'volume_max_réservoir' ]) >= 2 then
							return unit._unite{localdata[ 'volume_max_réservoir' ], 'millions de [[Mètre cube|m³]]'}
						else
							return unit._unite{localdata[ 'volume_max_réservoir' ], 'million de [[Mètre cube|m³]]'}
						end
					end
				end,
			},
			{
				type = 'row', 
				label = 'Volume normal', 
				value = function ( localdata )
					if tonumber(localdata[ 'volume_norm_réservoir' ]) then
						if tonumber(localdata[ 'volume_norm_réservoir' ]) >= 1000 then
							return unit._unite{tonumber(localdata[ 'volume_norm_réservoir' ])/1000, '[[Mètre cube|km³]]'}
						elseif tonumber(localdata[ 'volume_norm_réservoir' ]) >= 2 then
							return unit._unite{localdata[ 'volume_norm_réservoir' ], 'millions de [[Mètre cube|m³]]'}
						else
							return unit._unite{localdata[ 'volume_norm_réservoir' ], 'million de [[Mètre cube|m³]]'}
						end
					end
				end,
			},
			{
				type = 'row', 
				label = 'Volume utile', 
				value = function ( localdata )
					if tonumber(localdata[ 'volume_utile_réservoir' ]) then
						if tonumber(localdata[ 'volume_utile_réservoir' ]) >= 1000 then
							return unit._unite{tonumber(localdata[ 'volume_utile_réservoir' ])/1000, '[[Mètre cube|km³]]'}
						elseif tonumber(localdata[ 'volume_utile_réservoir' ]) >= 2 then
							return unit._unite{localdata[ 'volume_utile_réservoir' ], 'millions de [[Mètre cube|m³]]'}
						else
							return unit._unite{localdata[ 'volume_utile_réservoir' ], 'million de [[Mètre cube|m³]]'}
						end
					end
				end,
			},
			{
				type = 'row', 
				label = 'Superficie', 
				value = function ( localdata )
					if tonumber(localdata[ 'surface_réservoir' ]) then
						if tonumber(localdata[ 'surface_réservoir' ]) >= 100 then
							return unit._unite{tonumber(localdata[ 'surface_réservoir' ])/100,'[[Mètre carré|km²]]'}
						else
							return unit._unite{localdata[ 'surface_réservoir' ],'[[hectare|ha]]'}
						end
					end
				end,
				wikidata = {entity = reservoirid, property = 'P2046', showlink = true, condition = function() return reservoirid end}
			},
			{
				type = 'row', 
				label = 'Longueur', 
				value = function ( localdata )
					if localdata[ 'longueur_réservoir' ] then
						return unit._unite{localdata[ 'longueur_réservoir' ],'[[Kilomètre|km]]'}
					end
				end,
				wikidata = {entity = reservoirid, property = 'P2043', showlink = true, condition = function() return reservoirid end}
			},
		}},
		{type = 'table', title = 'Centrale(s) hydroélectrique(s)', rows = {
			{type = 'row1col', value = localdata[ 'nom_centrale' ]},
			coord_centrale(localdata['longitude centrale'], localdata['latitude centrale']),
			{type = 'row', label = 'Exploitant', value = 'exploitant'},
			{type = 'row', label = 'Type de centrale', value = 'type_centrale'},
			{
				type = 'row',
				label = 'Hauteur de chute',
				value = function ( localdata )
					if localdata[ 'hauteur_chute' ] then
						return unit._unite{localdata[ 'hauteur_chute' ],'[[Mètre|m]]'}
					end
				end,
			},
			{
				type = 'row',
				label = "Débit d'équipement",
				value = function ( localdata )
					if localdata[ 'débit_équipement' ] then
						return unit._unite{localdata[ 'débit_équipement' ],'m³/s'}
					end
				end,
			},
			{type = 'row', label = 'Nombre de turbines', value = 'nbr_turbine'},
			{type = 'row', label = 'Type de turbines', value = 'type_turbine'},
			{type = 'row', label = 'Nombre de turbines-pompes', value = 'nbr_turbine-pompe'},
			{type = 'row', label = 'Type de turbines-pompes', value = 'type_turbine-pompe'},
			{
				type = 'row', 
				label = 'Puissance installée', 
				value = function ( localdata )
					if localdata[ 'puissance_installée' ] then
						if localdata[ 'puissance_installée_unité' ] then
							return unit._unite{localdata[ 'puissance_installée' ],localdata[ 'puissance_installée_unité' ]}
						else
							return unit._unite{localdata[ 'puissance_installée' ],'[[Watt|MW]]'}
						end
					elseif localdata[ 'capacité_énergie' ] then
						if localdata[ 'capacité_énergie_unité' ] then
							return unit._unite{localdata[ 'capacité_énergie' ],localdata[ 'capacité_énergie_unité' ]}
						else
							return unit._unite{localdata[ 'capacité_énergie' ],'[[Watt|MW]]'}
						end
					end
				end,
				wikidata = {property = 'P2109', showlink = true}
			},
			{
				type = 'row', 
				label = 'Production annuelle', 
				value = function ( localdata )
					if tonumber(localdata[ 'production_énergie' ]) then
						if localdata[ 'production_énergie_unité' ] then
							return unit._unite{tonumber(localdata[ 'production_énergie' ]),localdata[ 'production_énergie_unité' ]}
						elseif tonumber(localdata[ 'production_énergie' ]) >= 1000 then
							return unit._unite{tonumber(localdata[ 'production_énergie' ])/1000,'[[Watt-heure|TWh/an]]'}
						else
							return unit._unite{tonumber(localdata[ 'production_énergie' ]),'[[Watt-heure|GWh/an]]'}
						end
					end
				end,
				wikidata = {property = 'P4131', showdate = 'true', numval = 1, sorttype = 'inverted', showlink = true}
			},
			power.facteurcharge(),
		}},
		{type = 'table', separator = true, rows = {	
			{type = 'row1col', value = localdata[ 'nom_centrale 2' ]},
			coord_centrale(localdata['longitude centrale 2'], localdata['latitude centrale 2']),
			{type = 'row', label = 'Type de centrale', value = 'type_centrale 2'},
			{
				type = 'row',
				label = 'Hauteur de chute',
				value = function ( localdata )
					if localdata[ 'hauteur_chute 2' ] then
						return unit._unite{localdata[ 'hauteur_chute 2' ],'[[Mètre|m]]'}
					end
				end,
			},
			{
				type = 'row',
				label = "Débit d'équipement",
				value = function ( localdata )
					if localdata[ 'débit_équipement 2' ] then
						return unit._unite{localdata[ 'débit_équipement 2' ],'m³/s'}
					end
				end,
			},
			{type = 'row', label = 'Nombre de turbines', value = 'nbr_turbine 2'},
			{type = 'row', label = 'Type de turbines', value = 'type_turbine 2'},
			{
				type = 'row', 
				label = 'Puissance installée',
				value = function ( localdata )
					if localdata[ 'puissance_installée 2' ] then
						if localdata[ 'puissance_installée_unité' ] then
							return unit._unite{localdata[ 'puissance_installée 2' ],localdata[ 'puissance_installée_unité' ]}
						else
							return unit._unite{localdata[ 'puissance_installée 2' ],'[[Watt|MW]]'}
						end
					elseif localdata[ 'capacité_énergie 2' ] then
						if localdata[ 'capacité_énergie_unité' ] then
							return unit._unite{localdata[ 'capacité_énergie 2' ],localdata[ 'capacité_énergie_unité' ]}
						else
							return unit._unite{localdata[ 'capacité_énergie 2' ],'[[Watt|MW]]'}
						end
					end
				end,
			},
			{
				type = 'row',
				label = 'Production annuelle',
				value = function ( localdata )
					if tonumber(localdata[ 'production_énergie 2' ]) then
						if localdata[ 'production_énergie_unité 2' ] then
							return unit._unite{tonumber(localdata[ 'production_énergie 2' ]),localdata[ 'production_énergie_unité 2' ]}
						elseif tonumber(localdata[ 'production_énergie 2' ]) >= 1000 then
							return unit._unite{tonumber(localdata[ 'production_énergie 2' ])/1000,'[[Watt-heure|TWh/an]]'}
						else
							return unit._unite{tonumber(localdata[ 'production_énergie 2' ]),'[[Watt-heure|GWh/an]]'}
						end
					end
				end,
			},
			{type = 'row', label = "[[Facteur de charge (électricité)|Facteur de charge]]", value = 'facteur_utilisation 2'},
		}},
		{type = 'table', title = 'Irrigation', rows = {
			{
				type = 'row',
				label = '[[Irrigation|Surface irriguée]]',
				value = function ( localdata )
					if localdata[ 'surface_irriguée' ] then
						return unit._unite{localdata[ 'surface_irriguée' ],'[[hectare|ha]]'}
					end
				end,
			},
			{type = 'row', label = 'Bassin(s) irrigué(s)', value = 'bassin_irrigué'},
		}},
		{type = 'table', separator = true, rows = {
			{type = 'row', label = 'Site web', value = 'url', property = 'P856'},
			{type = 'row', label = 'Source', value = 'source'},
		}},
		general.geoloc({marker = 'dam', default_zoom=11, pointtype=point})
	}
}