Aller au contenu

Module:Infobox/Relief

Une page de Wikipédia, l'encyclopédie libre.
Ceci est une version archivée de cette page, en date du 2 octobre 2016 à 14:57 et modifiée en dernier par J. N. Squire (discuter | contributions) (Annulation des modifications 130250765 de Feldo (d) ne permet pas de faire côtoyer deux déclarations). Elle peut contenir des erreurs, des inexactitudes ou des contenus vandalisés non présents dans la version actuelle.

 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:Interface Wikidata".fromLua
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, 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"}
	return wdGlobe[ "http://www.wikidata.org/entity/" .. p376 ]
end

return {
	maincolor = '#FFDEAD',
	parts = {
		general.title(),
		general.mainimage(), --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', 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', property = 'P170'}, -- dans le cas d'une montagne ou d'une patera
			general.coordinates(),
			{type = 'row', label = 'Altitude', value = 'altitude'},
			{type = 'row', label = 'Point culminant', value = 'pculminant', property = 'P2044'},
			{type = 'row', label = 'Rayon', value = 'rayon', property = 'P2120'},
			{type = 'row', label = 'Diamètre', value = 'diamètre', property = 'P2386'}, -- propriété à rendre prioritaire sur le rayon
			{type = 'row', label = 'Longueur', value = 'longueur', property = 'P2043'},
			{type = 'row', label = 'Largeur', value = 'largeur', property = 'P2049'},
			{type = 'row', label = 'Pente', value = 'pentes'},
			{type = 'row', label = 'Superficie', value = 'surface', wikidata = {property = 'P2046', targetunit = 'square kilometer'}},
			{type = 'row', label = 'Hauteur', value = 'hauteur', wikidata = {property = 'P2048', targetunit = 'm'}},
			{type = 'row', label = 'Profondeur', value = 'profondeur', wikidata = {property = 'P2610', targetunit = 'm'}},
			{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 = {
					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', property = 'P31'},
			{type = 'row', label = 'Nature', value = 'nature'}, -- obsolète car maintenant inclu dans la propriété type
			{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', property = 'P61'},
			{type = 'row', label = 'Date de découverte', value = 'date', property = 'P575'},
			{type = 'row', label = 'Éponyme', value = 'éponyme', property = 'P138'}
		}},
		geolocalisation.geoloc{ pointtype = getMapPoint(), globe = globe() },
	}
}