Module:Infobox/Fonctions/Géolocalisation

De Lagny-sur-Marne Wiki
< Module:Infobox‎ | Fonctions
Révision datée du 24 septembre 2014 à 14:00 par Zolo (discussion) (Nouvelle page : local coord = require('Module:Coordinates') local wikidatamod = require('Module:Wikidata') function p.coordinates(params) if not params then params = {} end return function(loc...)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Aller à : navigation, rechercher

La documentation pour ce module peut être créée à Module:Infobox/Fonctions/Géolocalisation/doc

local coord = require('Module:Coordinates')
local wikidatamod = require('Module:Wikidata')

function p.coordinates(params)
	if not params then params = {} end
	return function(localdata, item)
	if localdata["géolocalisation"] == 'pas pertinent' or localdata['géolocalisation'] == 'non' then
		if not localdata['coordonnées'] == 'oui' then
		return nil
	end end
	local displayformat = displaycoords

	local displaytitle = 'title'
	if params['displaytitle'] == false then
		displaytitle = ''
	end
	if localdata['coords en titre'] == 'non' then -- paramètre sur la page, domine les params du module
		displaytitle = ''
	end

	local displayinline = 'inline'
	if params['displayinline'] == false then
		displayinline = ''
	end
	if localdata[ 'coords en ligne'] == 'non' then
		displayinline = ''
	end

	local displayplace = displaytitle .. ',' .. displayinline
	local latitude = localdata['latitude']
	local longitude = localdata['longitude']
	local globe = localdata['globe']
	local wikidata = localdata['wikidata'] or 'true'
	if displayinline == '' then return -- type: external text pour ne pas avoir de ligne vide en infobox
		{
		type = 'external text',
		maintenancecat = 'Page géolocalisable sans coordonnées paramétrées',
		sortkey = sortkey,
 		value =
 			function(localdata, item)
 				return coord._coord({latitude = latitude, longitude = longitude, displayformat = displayformat, display= displayplace, globe = globe, wikidata =wikidata})
 			end
 	}
 	else return
 			{
		type = 'mixed',
		label = 'Coordonnées',
		maintenancecat = 'Page géolocalisable sans coordonnées paramétrées',
		sortkey = sortkey,
 		value =
 			function(localdata, item)
 				return coord._coord({latitude = latitude, longitude = longitude, displayformat = displayformat, display= displayplace, globe = globe, wikidata =wikidata})
 			end
 		}	
	end end
end

function p.geoloc()
	return   {
		type = 'map',
		wikidata = function(localdata, item) return wikidatamod.getClaims{item = item, property = 'P625'} end,
		maps = function(localdata, item) if localdata['géolocalisation'] then return mw.text.split( localdata['géolocalisation'], '/', true ) end end
        }
 
end