Module:Infobox/Fonctions/Géolocalisation : Différence entre versions

De Lagny-sur-Marne Wiki
Aller à : navigation, rechercher
(?)
Ligne 6 : Ligne 6 :
 
return function(localdata, item)
 
return function(localdata, item)
 
if localdata["géolocalisation"] == 'pas pertinent' or localdata['géolocalisation'] == 'non' then
 
if localdata["géolocalisation"] == 'pas pertinent' or localdata['géolocalisation'] == 'non' then
if not localdata['coordonnées'] == 'oui' then
+
if not (localdata['coordonnées'] == 'oui') then
 
return nil
 
return nil
 
end end
 
end end

Version du 24 septembre 2014 à 15:09

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')
local p = {}
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
return p