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

Utilisation

Fonctions exportables :

  • fonction(frame) – description (courte description de fonction(frame) et autres informations pertinentes).
  • fonction2() – description2 (courte description de fonction2() et autres informations pertinentes).

Autres fonctions :

  • fonction() – description2 (courte description de fonction() et autres informations pertinentes).

Modules externes et autres éléments dont ce module a besoin pour fonctionner :

  • mw.title – description (courte description expliquant la dépendance de ce module externe).

Exemples

Pour des exemples, voir la page de test permettant de tester diverses modifications apportées.

local localdata = require "Module:Infobox/Localdata"
local general = require "Module:Infobox/Fonctions"
local geolocalisation = require "Module:Infobox/Fonctions/Géolocalisation"
local wd = require "Module:Wikidata"
local wdGlobe = require "Module:Wikidata/Globes"

local function getMapPoint() -- type de point sur la carte
	local bodytype = localdata['type'] or wd.formatStatements{property = 'P31', entity = localdata.item, displayformat = "raw", numval = 1}	
	local points = {
	-- par paramètre local |type = 
		["[[lacus]]"] = "lac",
	
	-- id wikidata
		Q3215913 = "lac",
	}
	
	return points[mw.ustring.lower(bodytype or '')] or 'default'
end

local function age()
	local s = wd.formatAndCat{entity = localdata.item, showsource = 'true', property = "P571", conjtype= "or"}
	if s then
		return "il y a " .. s
	end
end

local function globe()
	if localdata.globe then
		return localdata.globe
	end
	local p376 = wd.formatStatements{property = 'P376', entity = localdata.item, displayformat = "raw"}
	if p376 then
		return wdGlobe[ "http://www.wikidata.org/entity/" .. p376 ]
	end
end

return {
	maincolor = '#FFDEAD',
	parts = {
		general.title(),
		general.mainimage('Article à illustrer Géographie planétaire'), --rajouter upright
		{type = 'table', title = 'Géographie', rows = {
			{type = 'row', label = 'Nom international', value = 'nom international', property = 'P1448'}, -- nom donné par l'UAI
			{type = 'row', label = 'Astre', value = {'astre', 'planète'}, property = 'P376'}, -- corps astronomique où se trouve le lieu dont il est question
			{type = 'row', label = 'Continent', value = 'continent', property = 'P30'}, -- dans le cas d'une planète de type terrestre uniquement
			{type = 'row', label = 'Pays', plurallabel = 'Pays', value = {'pays', 'pays1', 'pays2', 'pays3'}, property = 'P17'}, -- le ou les pays où se trouve de facto la structure si elle est sur Terre
			{type = 'row', label = 'Subdivision administrative', plurallabel = 'Subdivisions administratives', value = {'unité_admin', 'pays1_nom_subdivision1', 'pays1_nom_subdivision2', 'pays1_nom_subdivision3'}, property = 'P131'}, -- unité administrative minimale pour les structures terrestres
			{type = 'row', label = 'Région', plurallabel = 'Régions', value = 'région', property = 'P706'}, -- régions géographiques sans quadrangle
			{type = 'row', label = 'Massif', value = 'massif', wikidata = {property = 'P170', showsource = true}}, -- dans le cas d'une montagne ou d'une patera
			geolocalisation.coordinates{ globe = globe()  },
			{type = 'row', label = '[[ Altitudes et coordonnées géographiques sur les corps célestes|Altitude]]', value = {'altitude','pculminant'}, wikidata = {property = 'P2044', showsource = true}},
			{type = 'row', label = 'Rayon', value = 'rayon', wikidata = {property = 'P2120', showsource = true}},
			{type = 'row', label = 'Diamètre', value = 'diamètre', wikidata = {property = 'P2386', showsource = true}}, -- propriété à rendre prioritaire sur le rayon
			{type = 'row', label = 'Longueur', value = 'longueur', wikidata = {property = 'P2043', showsource = true}},
			{type = 'row', label = 'Largeur', value = 'largeur', wikidata = {property = 'P2049', showsource = true}},
			{type = 'row', label = 'Pente', value = 'pentes', wikidata = {property = 'P4184', showsource = true}},
			{type = 'row', label = 'Superficie', value = 'surface', wikidata = {property = 'P2046', targetunit = 'square kilometer', showsource = true}},
			{type = 'row', label = 'Hauteur', value = 'hauteur', wikidata = {property = 'P2048', targetunit = 'm', showsource = true}},
			{type = 'row', label = 'Profondeur', value = 'profondeur', wikidata = {property = 'P4511', targetunit = 'm', showsource = true}},
			{type = 'row', label = 'Dimensions de la caldeira', value = 'dcaldera'},-- pour un volcan
			{type = 'row', label = 'Profondeur de la caldeira', value = 'pcaldera'},-- pour un volcan
			{
				type = 'row', --quadrangles (Q7268308) indiqués avec la propriété lieu
				label = 'Quadrangle',
				plurallabel = 'Quadrangles',
				value = 'quadrangle',
				wikidata = {
					showsource = 'true',
					property = 'P276',
					conjtype = 'and',
					labelformat = function(entity)
						local label = wd.getLabel(entity)
						if not label then
							return nil
						end
						label = mw.ustring.gsub(label, "quadrangle d'", "")
						label = mw.ustring.gsub(label, "quadrangle de", "")
						return label
					end,
					condition = function(claim) -- vérifie qu'il s'agit d'un quadrangle
						local v = wd.getMainId(claim)
						return wd.isInstance("Q7268308", v, 1)
					end,
				}
			},
		}},
		{type = 'table', title = 'Géologie', rows = {
			{type = 'row', label = 'Époque de formation', value = 'âge', wikidata = age()},
			{type = 'row', label = 'Type', plurallabel = 'Types', value = 'type', wikidata = {property = 'P31', showsource = true}},
			{type = 'row', label = 'Nature', value = 'nature'}, -- obsolète car maintenant inclu dans la propriété 'type'
			{type = 'row', label = 'Âge estimé', value = 'age', wikidata = {property = 'P7584', showsource = true}}, -- âge du relief, souvent obtenu par dénombrement des cratères d'impact
			{type = 'row', label = 'Activité', value = 'activité'},
		}},
			{type = 'table', title = 'Impacteur', rows = {
			{type = 'row', label = 'Nature', value = 'impacteur nature'},
			{type = 'row', label = 'Diamètre', value = 'impacteur diamètre'},
			{type = 'row', label = 'Vitesse', value = 'impacteur vitesse'},
			{type = 'row', label = 'Angle', value = 'impacteur angle'},
			{type = 'row', label = 'Densité', value = 'impacteur densité'},
		}},
			{type = 'table', title = 'Cible', rows = {
			{type = 'row', label = 'Nature', value = 'cible nature'},
			{type = 'row', label = 'Densité', value = 'cible densité'},
		}},
		{type = 'table', title = 'Exploration', rows = {
			{type = 'row', label = 'Découvreur', plurallabel = 'Découvreurs', value = 'découvreur', wikidata = {property = 'P61', showsource = true}},
			{type = 'row', label = 'Date de découverte', plurallabel = 'Dates de découverte', value = 'date', wikidata = {property = 'P575', showsource = true}},
			{type = 'row', label = 'Éponyme', plurallabel = 'Éponymes', value = 'éponyme', wikidata = {property = 'P138', showsource = true}}
		}},
		geolocalisation.geoloc{ pointtype = getMapPoint(), globe = globe() },
	}
}