Wikicode de la page après la modification (new_wikitext) | 'local p = {}
local coord = require( "Module:Coordinates" )
local function normalise(args)
local lookup_table = {
['largeur'] = 'width',
['hauteur'] = 'height',
['texte'] = 'text',
['legende'] = 'text',
['légende'] = 'text',
['déscription'] = 'description',
['titre'] = 'title',
['sans_cadre'] = 'frameless',
['symbole'] = 'symbol',
['couleur'] = 'color',
['taille'] = 'size',
['epaisseur'] = 'size',
['épaisseur'] = 'size',
['opacite'] = 'opacity',
['opacité'] = 'opacity',
['epaisseur contour'] = 'outline_size',
['épaisseur contour'] = 'outline_size',
['couleur contour'] = 'outline_color',
['opacite contour'] = 'opacity',
['opacité contour'] = 'opacity',
['couleur fond'] = 'fill_color',
['opacite fond'] = 'fill_opacity',
['opacité fond'] = 'fill_opacity',
['geoline'] = 'contour',
['requête'] = 'query',
['requete'] = 'query',
['request'] = 'query',
['langue'] = 'lang',
}
for k, v in pairs(lookup_table) do
if args[k] ~= nil then
args[v] = args[k]
end
end
return args
end
local function decodeJsonList(value)
--[[ Plusieurs modèles, dont {{Carte interactive/Marqueur}}, ajoutent des
virgules à la fin des représentations JSON des objets. Cela fonctionne avec
le parsing JSON relaxé de HHVM, mais pas PHP7. Ce bug est détaillé ici:
https://phabricator.wikimedia.org/T214984
Cette fonction retire donc les virgules finales et initiales, avant
d'appeler mw.text.jsonDecode sur la liste.
]]
local trimmedValue = mw.text.trim(value, ',')
return mw.text.jsonDecode('[' .. trimmedValue .. ']')
end
function p.marker(frame)
local args = normalise(frame:getParent().args)
if args[1] == nil and args.latlng == nil then --One coordinate is mandatory
return
end
local properties = {
['marker-color'] = args.color == nil and '#555555' or args.color,
['marker-size'] = args.size == nil and 'medium' or args.size,
['marker-symbol'] = args.symbol == nil and '' or args.symbol,
['title'] = args.title == nil and '' or args.title,
['description'] = args.description == nil and '' or args.description,
}
local latlng = mw.text.split( (args[1] == nil and args.latlng or args[1]), ",", true )
if args.randomise ~= nil then
latlng[1] = latlng[1] + math.random(-tonumber(args.randomise), tonumber(args.randomise))/100000
latlng[2] = latlng[2] + math.random(-tonumber(args.randomise), tonumber(args.randomise))/100000
end
local geojson = {
type = "Feature",
properties = properties,
geometry = {
type = "Point",
coordinates = {
tonumber(latlng[2]),
tonumber(latlng[1]),
}
}
}
return mw.text.jsonEncode(geojson) .. ','
end
function p.line(frame)
local args = normalise(frame:getParent().args)
if args[2] == nil then --At least two coordinates are mandatory
return
end
local properties = {
["stroke"] = args.color == nil and '#555555' or args.color,
["stroke-width"] = args.size == nil and 2 or tonumber(args.size),
["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),
['title'] = args.title == nil and '' or args.title,
['description'] = args.description == nil and '' or args.description,
}
local coordinates = {}
local i = 1
while args[i] ~= nil do
local latlng = mw.text.split( args[i], ",", true )
coordinates[i] = {
tonumber(latlng[2]),
tonumber(latlng[1]),
}
i = i+1
end
local geojson = {
type = "Feature",
properties = properties,
geometry = {
type = "LineString",
coordinates = coordinates
}
}
return mw.text.jsonEncode(geojson) .. ','
end
function p.polygon(frame)
local args = normalise(frame:getParent().args)
if args[3] == nil then --At least three coordinates are mandatory
return
end
local properties = {
["stroke"] = args.color == nil and '#555555' or args.color,
["stroke-width"] = args.size == nil and 2 or tonumber(args.size),
["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),
["fill"] = args.fill_color == nil and '#555555' or args.fill_color,
["fill-opacity"] = args.fill_opacity == nil and 0.3 or tonumber(args.fill_opacity),
['title'] = args.title == nil and '' or args.title,
['description'] = args.description == nil and '' or args.description,
}
local coordinates = {}
local i = 1
while args[i] ~= nil do
local latlng = mw.text.split( args[i], ",", true )
coordinates[i] = {
tonumber(latlng[2]),
tonumber(latlng[1]),
}
i = i+1
end
local latlng = mw.text.split( args[1], ",", true )
coordinates[i] = {
tonumber(latlng[2]),
tonumber(latlng[1]),
}
local geojson = {
type = "Feature",
properties = properties,
geometry = {
type = "Polygon",
coordinates = { coordinates }
}
}
return mw.text.jsonEncode(geojson) .. ','
end
function p.query(frame)
local args = normalise(frame:getParent().args)
local query
if args[1] ~= nil then
query = args[1]
else
return
end
local properties = {
["stroke"] = args.color == nil and '#555555' or args.color,
["stroke-width"] = args.size == nil and 2 or tonumber(args.size),
["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),
["fill"] = args.fill_color == nil and '#555555' or args.fill_color,
["fill-opacity"] = args.fill_opacity == nil and 0.3 or tonumber(args.fill_opacity),
['title'] = args.title == nil and '' or args.title,
['description'] = args.description == nil and '' or args.description,
}
local service = "geoshape"
if args.contour ~= nil then
service = "geoline"
end
local geojson = {
type = "ExternalData",
service = service,
query = query,
properties = properties,
}
return mw.text.jsonEncode(geojson) .. ','
end
function p.osm(frame)
local args = normalise(frame:getParent().args)
local qid
if args[1] == nil then
qid = mw.wikibase.getEntityIdForCurrentPage()
else
qid = mw.text.trim(args[1])
end
local properties = {
["stroke"] = args.color == nil and '#555555' or args.color,
["stroke-width"] = args.size == nil and 2 or tonumber(args.size),
["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),
["fill"] = args.fill_color == nil and '#555555' or args.fill_color,
["fill-opacity"] = args.fill_opacity == nil and 0.3 or tonumber(args.fill_opacity),
['title'] = args.title == nil and '' or args.title,
['description'] = args.description == nil and '' or args.description,
}
local service = "geoshape"
if args.contour ~= nil then
service = "geoline"
end
local geojson = {
type = "ExternalData",
service = service,
ids = qid,
properties = properties,
}
return mw.text.jsonEncode(geojson) .. ','
end
function p.commons(frame)
local args = normalise(frame:getParent().args)
if args[1] == nil then
return
end
local page_name = args[1]
if mw.ustring.find(page_name, "Data:", 1, true) == 1 then
page_name = string.sub(page_name, 6)
end
if mw.ustring.find(page_name, ".map", -4, true) == nil then
page_name = page_name .. '.map'
end
local geojson = {
type = "ExternalData",
service = "page",
title = page_name
}
return mw.text.jsonEncode(geojson) .. ','
end
function p.wikidata(frame)
local args = normalise(frame:getParent().args)
local qid
local properties = {
['marker-color'] = args.color == nil and '#555555' or args.color,
['marker-size'] = args.size == nil and 'medium' or args.size,
['marker-symbol'] = args.symbol == nil and '' or args.symbol,
['title'] = args.title == nil and '' or args.title,
['description'] = args.description == nil and '' or args.description,
}
if args[1] == nil then
qid = mw.wikibase.getEntityIdForCurrentPage()
else
qid = args[1]
end
local entity = mw.wikibase.getEntity( qid )
local value = entity:formatPropertyValues( 'P625', { mw.wikibase.entity.claimRanks.RANK_NORMAL, mw.wikibase.entity.claimRanks.RANK_PREFERRED, mw.wikibase.entity.claimRanks.RANK_TRUTH } ).value
if value == nil then
error('La propriété P625 "coordonnées géographiques" n\'est pas renseigné sur Wikidata')
end
latlng = mw.text.split( mw.text.decode(value), ", ", true )
geojson = {
type = "Feature",
geometry = {
type = "Point",
coordinates = {
coord._dms2dec(coord._parsedmsstring(latlng[2])),
coord._dms2dec(coord._parsedmsstring(latlng[1]))
}
},
properties = properties
}
return mw.text.jsonEncode(geojson) .. ','
end
function p.tag(frame)
local args = ( frame.getParent and normalise(frame:getParent().args) ) or frame
-- Choose the tagname
local tagname = 'mapframe'
if args.lien ~= nil then
tagname = 'maplink'
end
-- Manage the basics tag params
local tagArgs = {
zoom = args.zoom == nil and args.commons == nil and 14 or tonumber(args.zoom),
height = args.height == nil and 420 or tonumber(args.height),
width = args.width == nil and 420 or tonumber(args.width),
align = args.align == nil and 'right' or args.align,
text = args.text,
}
if args[1] ~= nil and (args.latitude ~= nil or args.longitude ~= nil) then
error('La ou les valeurs de longitude et/ou de latitude ont été fournis via deux syntaxe différentes. Consultez la documentation du [[Modèle:Carte interactive]] pour obtenir une syntaxe correcte')
elseif args.latitude ~= nil and args.latitude ~= ''
and args.longitude ~= nil and args.longitude ~= '' then
tagArgs.latitude = args.latitude
tagArgs.longitude = args.longitude
elseif args[1] ~= nil and args[2] ~= nil then
tagArgs.latitude = args[1]
tagArgs.longitude = args[2]
elseif args.commons == nil and args.wikidata == nil
and args.formes == nil and args.query == nil and args.externes == nil then --The only exceptions allowed to put latitude and longitude away are when using an external map stored on commons, coord from wikidata, formes, query or externes
error('Les paramètres de latitude et/ou de longitude sont absent')
end
if tagArgs.latitude ~= nil and tagArgs.longitude ~= nil then
if tonumber(tagArgs.latitude) then
tagArgs.latitude = tonumber(tagArgs.latitude)
else
tagArgs.latitude = coord._dms2dec(coord._parsedmsstring(tagArgs.latitude))
end
if tonumber(tagArgs.longitude) then
tagArgs.longitude = tonumber(tagArgs.longitude)
else
tagArgs.longitude = coord._dms2dec(coord._parsedmsstring(tagArgs.longitude))
end
end
if args.frameless then
tagArgs.frameless = ''
end
if args.lang ~= nil then
tagArgs.lang = args.lang
end
-- Manage the basics GeoJSON params
local geojson = {}
if args.commons ~= nil then
geojson[#geojson+1] = {
type = "ExternalData",
service = "page",
title = args.commons,
}
end
if args.marqueur ~= nil and args.marqueur ~= '' then
geojson[#geojson+1] = {
type = "Feature",
geometry = {
type = "Point",
coordinates = {
tagArgs.longitude,
tagArgs.latitude
}
},
properties = {
['marker-color'] = (args.color == nil or args.color == '') and '#555555' or args.color,
['marker-size'] = (args.size == nil or args.size == '') and 'medium' or args.size,
['marker-symbol'] = args.symbol == nil and '' or args.symbol,
['title'] = args.title == nil and '' or args.title,
['description'] = args.description == nil and '' or args.description,
}
}
end
if args.osm ~= nil and args.osm ~= '' then
local qid
if args.osm == 'oui' then
qid = mw.wikibase.getEntityIdForCurrentPage()
if qid == nil then
qid = "Q1"
end
else
qid = args.osm
end
local service = "geoshape"
if args.contour ~= nil then
service = "geoline"
end
geojson[#geojson+1] = {
type = "ExternalData",
service = service,
ids = qid,
properties = {
['title'] = args.title == nil and '' or args.title,
['description'] = args.description == nil and '' or args.description,
['stroke'] = args.outline_color == nil and '#555555' or args.outline_color,
['stroke-width'] = args.outline_size == nil and 2 or tonumber(args.outline_size),
}
}
end
local qid = args.wikidata
if qid and not mw.wikibase.isValidEntityId( qid ) then
qid = mw.wikibase.getEntityIdForCurrentPage()
end
if qid and mw.wikibase.isValidEntityId( qid ) then
local entity = mw.wikibase.getEntity( qid )
local value = entity:formatPropertyValues( 'P625', { mw.wikibase.entity.claimRanks.RANK_NORMAL, mw.wikibase.entity.claimRanks.RANK_PREFERRED, mw.wikibase.entity.claimRanks.RANK_TRUTH } ).value
if value == '' then
error('La propriété P625 "coordonnées géographiques" n\'est pas renseigné sur Wikidata')
end
latlng = mw.text.split( mw.text.decode(value), ", ", true )
geojson[#geojson+1] = {
type = "Feature",
geometry = {
type = "Point",
coordinates = {
coord._dms2dec(coord._parsedmsstring(latlng[2])),
coord._dms2dec(coord._parsedmsstring(latlng[1]))
}
},
properties = {
title = args.title == nil and '' or args.title,
description = args.description == nil and '' or args.description,
}
}
end
if args.query ~= nil then
local service = "geoshape"
if args.contour ~= nil then
service = "geoline"
end
geojson[#geojson+1] = {
type = "ExternalData",
service = service,
query = args.query,
properties = {
title = args.title == nil and '' or args.title,
description = args.description == nil and '' or args.description,
}
}
end
--Manage external GeoJSON datas included through models
if args.formes ~= nil then
geojson[#geojson+1] = {
type = "FeatureCollection",
features = decodeJsonList(args.formes)
}
end
if args.externes ~= nil and args.externes ~= '' then
local externes = decodeJsonList(args.externes)
for k, externe in pairs(externes) do
geojson[#geojson+1] = externe
end
end
return frame:extensionTag(tagname, mw.text.jsonEncode(geojson), tagArgs)
end
return' |
Diff unifié des changements faits lors de la modification (edit_diff) | '@@ -1,0 +1,479 @@
+local p = {}
+local coord = require( "Module:Coordinates" )
+
+local function normalise(args)
+ local lookup_table = {
+ ['largeur'] = 'width',
+ ['hauteur'] = 'height',
+ ['texte'] = 'text',
+ ['legende'] = 'text',
+ ['légende'] = 'text',
+ ['déscription'] = 'description',
+ ['titre'] = 'title',
+ ['sans_cadre'] = 'frameless',
+ ['symbole'] = 'symbol',
+ ['couleur'] = 'color',
+ ['taille'] = 'size',
+ ['epaisseur'] = 'size',
+ ['épaisseur'] = 'size',
+ ['opacite'] = 'opacity',
+ ['opacité'] = 'opacity',
+ ['epaisseur contour'] = 'outline_size',
+ ['épaisseur contour'] = 'outline_size',
+ ['couleur contour'] = 'outline_color',
+ ['opacite contour'] = 'opacity',
+ ['opacité contour'] = 'opacity',
+ ['couleur fond'] = 'fill_color',
+ ['opacite fond'] = 'fill_opacity',
+ ['opacité fond'] = 'fill_opacity',
+ ['geoline'] = 'contour',
+ ['requête'] = 'query',
+ ['requete'] = 'query',
+ ['request'] = 'query',
+ ['langue'] = 'lang',
+ }
+
+ for k, v in pairs(lookup_table) do
+ if args[k] ~= nil then
+ args[v] = args[k]
+ end
+ end
+
+ return args
+end
+
+local function decodeJsonList(value)
+ --[[ Plusieurs modèles, dont {{Carte interactive/Marqueur}}, ajoutent des
+ virgules à la fin des représentations JSON des objets. Cela fonctionne avec
+ le parsing JSON relaxé de HHVM, mais pas PHP7. Ce bug est détaillé ici:
+ https://phabricator.wikimedia.org/T214984
+ Cette fonction retire donc les virgules finales et initiales, avant
+ d'appeler mw.text.jsonDecode sur la liste.
+ ]]
+ local trimmedValue = mw.text.trim(value, ',')
+ return mw.text.jsonDecode('[' .. trimmedValue .. ']')
+end
+
+function p.marker(frame)
+ local args = normalise(frame:getParent().args)
+
+ if args[1] == nil and args.latlng == nil then --One coordinate is mandatory
+ return
+ end
+
+ local properties = {
+ ['marker-color'] = args.color == nil and '#555555' or args.color,
+ ['marker-size'] = args.size == nil and 'medium' or args.size,
+ ['marker-symbol'] = args.symbol == nil and '' or args.symbol,
+ ['title'] = args.title == nil and '' or args.title,
+ ['description'] = args.description == nil and '' or args.description,
+ }
+
+ local latlng = mw.text.split( (args[1] == nil and args.latlng or args[1]), ",", true )
+
+ if args.randomise ~= nil then
+ latlng[1] = latlng[1] + math.random(-tonumber(args.randomise), tonumber(args.randomise))/100000
+ latlng[2] = latlng[2] + math.random(-tonumber(args.randomise), tonumber(args.randomise))/100000
+ end
+
+ local geojson = {
+ type = "Feature",
+ properties = properties,
+ geometry = {
+ type = "Point",
+ coordinates = {
+ tonumber(latlng[2]),
+ tonumber(latlng[1]),
+ }
+ }
+ }
+ return mw.text.jsonEncode(geojson) .. ','
+end
+
+function p.line(frame)
+ local args = normalise(frame:getParent().args)
+
+ if args[2] == nil then --At least two coordinates are mandatory
+ return
+ end
+
+ local properties = {
+ ["stroke"] = args.color == nil and '#555555' or args.color,
+ ["stroke-width"] = args.size == nil and 2 or tonumber(args.size),
+ ["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),
+ ['title'] = args.title == nil and '' or args.title,
+ ['description'] = args.description == nil and '' or args.description,
+ }
+
+ local coordinates = {}
+ local i = 1
+ while args[i] ~= nil do
+ local latlng = mw.text.split( args[i], ",", true )
+ coordinates[i] = {
+ tonumber(latlng[2]),
+ tonumber(latlng[1]),
+ }
+ i = i+1
+ end
+
+ local geojson = {
+ type = "Feature",
+ properties = properties,
+ geometry = {
+ type = "LineString",
+ coordinates = coordinates
+ }
+ }
+ return mw.text.jsonEncode(geojson) .. ','
+end
+
+function p.polygon(frame)
+ local args = normalise(frame:getParent().args)
+
+ if args[3] == nil then --At least three coordinates are mandatory
+ return
+ end
+
+ local properties = {
+ ["stroke"] = args.color == nil and '#555555' or args.color,
+ ["stroke-width"] = args.size == nil and 2 or tonumber(args.size),
+ ["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),
+ ["fill"] = args.fill_color == nil and '#555555' or args.fill_color,
+ ["fill-opacity"] = args.fill_opacity == nil and 0.3 or tonumber(args.fill_opacity),
+ ['title'] = args.title == nil and '' or args.title,
+ ['description'] = args.description == nil and '' or args.description,
+ }
+
+ local coordinates = {}
+ local i = 1
+ while args[i] ~= nil do
+ local latlng = mw.text.split( args[i], ",", true )
+ coordinates[i] = {
+ tonumber(latlng[2]),
+ tonumber(latlng[1]),
+ }
+ i = i+1
+ end
+ local latlng = mw.text.split( args[1], ",", true )
+ coordinates[i] = {
+ tonumber(latlng[2]),
+ tonumber(latlng[1]),
+ }
+
+ local geojson = {
+ type = "Feature",
+ properties = properties,
+ geometry = {
+ type = "Polygon",
+ coordinates = { coordinates }
+ }
+ }
+ return mw.text.jsonEncode(geojson) .. ','
+end
+
+function p.query(frame)
+ local args = normalise(frame:getParent().args)
+
+ local query
+ if args[1] ~= nil then
+ query = args[1]
+ else
+ return
+ end
+
+ local properties = {
+ ["stroke"] = args.color == nil and '#555555' or args.color,
+ ["stroke-width"] = args.size == nil and 2 or tonumber(args.size),
+ ["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),
+ ["fill"] = args.fill_color == nil and '#555555' or args.fill_color,
+ ["fill-opacity"] = args.fill_opacity == nil and 0.3 or tonumber(args.fill_opacity),
+ ['title'] = args.title == nil and '' or args.title,
+ ['description'] = args.description == nil and '' or args.description,
+ }
+
+ local service = "geoshape"
+ if args.contour ~= nil then
+ service = "geoline"
+ end
+
+ local geojson = {
+ type = "ExternalData",
+ service = service,
+ query = query,
+ properties = properties,
+ }
+ return mw.text.jsonEncode(geojson) .. ','
+end
+
+function p.osm(frame)
+ local args = normalise(frame:getParent().args)
+
+ local qid
+ if args[1] == nil then
+ qid = mw.wikibase.getEntityIdForCurrentPage()
+ else
+ qid = mw.text.trim(args[1])
+ end
+
+ local properties = {
+ ["stroke"] = args.color == nil and '#555555' or args.color,
+ ["stroke-width"] = args.size == nil and 2 or tonumber(args.size),
+ ["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),
+ ["fill"] = args.fill_color == nil and '#555555' or args.fill_color,
+ ["fill-opacity"] = args.fill_opacity == nil and 0.3 or tonumber(args.fill_opacity),
+ ['title'] = args.title == nil and '' or args.title,
+ ['description'] = args.description == nil and '' or args.description,
+ }
+
+ local service = "geoshape"
+ if args.contour ~= nil then
+ service = "geoline"
+ end
+
+ local geojson = {
+ type = "ExternalData",
+ service = service,
+ ids = qid,
+ properties = properties,
+ }
+ return mw.text.jsonEncode(geojson) .. ','
+end
+
+function p.commons(frame)
+ local args = normalise(frame:getParent().args)
+
+ if args[1] == nil then
+ return
+ end
+
+ local page_name = args[1]
+ if mw.ustring.find(page_name, "Data:", 1, true) == 1 then
+ page_name = string.sub(page_name, 6)
+ end
+ if mw.ustring.find(page_name, ".map", -4, true) == nil then
+ page_name = page_name .. '.map'
+ end
+
+ local geojson = {
+ type = "ExternalData",
+ service = "page",
+ title = page_name
+ }
+ return mw.text.jsonEncode(geojson) .. ','
+end
+
+function p.wikidata(frame)
+ local args = normalise(frame:getParent().args)
+ local qid
+
+ local properties = {
+ ['marker-color'] = args.color == nil and '#555555' or args.color,
+ ['marker-size'] = args.size == nil and 'medium' or args.size,
+ ['marker-symbol'] = args.symbol == nil and '' or args.symbol,
+ ['title'] = args.title == nil and '' or args.title,
+ ['description'] = args.description == nil and '' or args.description,
+ }
+
+ if args[1] == nil then
+ qid = mw.wikibase.getEntityIdForCurrentPage()
+ else
+ qid = args[1]
+ end
+
+ local entity = mw.wikibase.getEntity( qid )
+ local value = entity:formatPropertyValues( 'P625', { mw.wikibase.entity.claimRanks.RANK_NORMAL, mw.wikibase.entity.claimRanks.RANK_PREFERRED, mw.wikibase.entity.claimRanks.RANK_TRUTH } ).value
+ if value == nil then
+ error('La propriété P625 "coordonnées géographiques" n\'est pas renseigné sur Wikidata')
+ end
+ latlng = mw.text.split( mw.text.decode(value), ", ", true )
+ geojson = {
+ type = "Feature",
+ geometry = {
+ type = "Point",
+ coordinates = {
+ coord._dms2dec(coord._parsedmsstring(latlng[2])),
+ coord._dms2dec(coord._parsedmsstring(latlng[1]))
+ }
+ },
+ properties = properties
+ }
+
+ return mw.text.jsonEncode(geojson) .. ','
+end
+
+function p.tag(frame)
+ local args = ( frame.getParent and normalise(frame:getParent().args) ) or frame
+
+ -- Choose the tagname
+ local tagname = 'mapframe'
+ if args.lien ~= nil then
+ tagname = 'maplink'
+ end
+
+ -- Manage the basics tag params
+ local tagArgs = {
+ zoom = args.zoom == nil and args.commons == nil and 14 or tonumber(args.zoom),
+ height = args.height == nil and 420 or tonumber(args.height),
+ width = args.width == nil and 420 or tonumber(args.width),
+ align = args.align == nil and 'right' or args.align,
+ text = args.text,
+ }
+
+ if args[1] ~= nil and (args.latitude ~= nil or args.longitude ~= nil) then
+ error('La ou les valeurs de longitude et/ou de latitude ont été fournis via deux syntaxe différentes. Consultez la documentation du [[Modèle:Carte interactive]] pour obtenir une syntaxe correcte')
+ elseif args.latitude ~= nil and args.latitude ~= ''
+ and args.longitude ~= nil and args.longitude ~= '' then
+ tagArgs.latitude = args.latitude
+ tagArgs.longitude = args.longitude
+ elseif args[1] ~= nil and args[2] ~= nil then
+ tagArgs.latitude = args[1]
+ tagArgs.longitude = args[2]
+ elseif args.commons == nil and args.wikidata == nil
+ and args.formes == nil and args.query == nil and args.externes == nil then --The only exceptions allowed to put latitude and longitude away are when using an external map stored on commons, coord from wikidata, formes, query or externes
+ error('Les paramètres de latitude et/ou de longitude sont absent')
+ end
+
+ if tagArgs.latitude ~= nil and tagArgs.longitude ~= nil then
+ if tonumber(tagArgs.latitude) then
+ tagArgs.latitude = tonumber(tagArgs.latitude)
+ else
+ tagArgs.latitude = coord._dms2dec(coord._parsedmsstring(tagArgs.latitude))
+ end
+ if tonumber(tagArgs.longitude) then
+ tagArgs.longitude = tonumber(tagArgs.longitude)
+ else
+ tagArgs.longitude = coord._dms2dec(coord._parsedmsstring(tagArgs.longitude))
+ end
+ end
+
+ if args.frameless then
+ tagArgs.frameless = ''
+ end
+
+ if args.lang ~= nil then
+ tagArgs.lang = args.lang
+ end
+
+ -- Manage the basics GeoJSON params
+ local geojson = {}
+
+ if args.commons ~= nil then
+ geojson[#geojson+1] = {
+ type = "ExternalData",
+ service = "page",
+ title = args.commons,
+ }
+ end
+
+ if args.marqueur ~= nil and args.marqueur ~= '' then
+ geojson[#geojson+1] = {
+ type = "Feature",
+ geometry = {
+ type = "Point",
+ coordinates = {
+ tagArgs.longitude,
+ tagArgs.latitude
+ }
+ },
+ properties = {
+ ['marker-color'] = (args.color == nil or args.color == '') and '#555555' or args.color,
+ ['marker-size'] = (args.size == nil or args.size == '') and 'medium' or args.size,
+ ['marker-symbol'] = args.symbol == nil and '' or args.symbol,
+ ['title'] = args.title == nil and '' or args.title,
+ ['description'] = args.description == nil and '' or args.description,
+ }
+ }
+ end
+
+ if args.osm ~= nil and args.osm ~= '' then
+ local qid
+ if args.osm == 'oui' then
+ qid = mw.wikibase.getEntityIdForCurrentPage()
+ if qid == nil then
+ qid = "Q1"
+ end
+ else
+ qid = args.osm
+ end
+
+ local service = "geoshape"
+ if args.contour ~= nil then
+ service = "geoline"
+ end
+
+ geojson[#geojson+1] = {
+ type = "ExternalData",
+ service = service,
+ ids = qid,
+ properties = {
+ ['title'] = args.title == nil and '' or args.title,
+ ['description'] = args.description == nil and '' or args.description,
+ ['stroke'] = args.outline_color == nil and '#555555' or args.outline_color,
+ ['stroke-width'] = args.outline_size == nil and 2 or tonumber(args.outline_size),
+ }
+ }
+ end
+
+ local qid = args.wikidata
+ if qid and not mw.wikibase.isValidEntityId( qid ) then
+ qid = mw.wikibase.getEntityIdForCurrentPage()
+ end
+ if qid and mw.wikibase.isValidEntityId( qid ) then
+ local entity = mw.wikibase.getEntity( qid )
+ local value = entity:formatPropertyValues( 'P625', { mw.wikibase.entity.claimRanks.RANK_NORMAL, mw.wikibase.entity.claimRanks.RANK_PREFERRED, mw.wikibase.entity.claimRanks.RANK_TRUTH } ).value
+ if value == '' then
+ error('La propriété P625 "coordonnées géographiques" n\'est pas renseigné sur Wikidata')
+ end
+ latlng = mw.text.split( mw.text.decode(value), ", ", true )
+ geojson[#geojson+1] = {
+ type = "Feature",
+ geometry = {
+ type = "Point",
+ coordinates = {
+ coord._dms2dec(coord._parsedmsstring(latlng[2])),
+ coord._dms2dec(coord._parsedmsstring(latlng[1]))
+ }
+ },
+ properties = {
+ title = args.title == nil and '' or args.title,
+ description = args.description == nil and '' or args.description,
+ }
+ }
+ end
+
+ if args.query ~= nil then
+ local service = "geoshape"
+ if args.contour ~= nil then
+ service = "geoline"
+ end
+
+ geojson[#geojson+1] = {
+ type = "ExternalData",
+ service = service,
+ query = args.query,
+ properties = {
+ title = args.title == nil and '' or args.title,
+ description = args.description == nil and '' or args.description,
+ }
+ }
+ end
+
+ --Manage external GeoJSON datas included through models
+ if args.formes ~= nil then
+ geojson[#geojson+1] = {
+ type = "FeatureCollection",
+ features = decodeJsonList(args.formes)
+ }
+ end
+
+ if args.externes ~= nil and args.externes ~= '' then
+ local externes = decodeJsonList(args.externes)
+ for k, externe in pairs(externes) do
+ geojson[#geojson+1] = externe
+ end
+ end
+
+ return frame:extensionTag(tagname, mw.text.jsonEncode(geojson), tagArgs)
+end
+
+return
' |
Lignes ajoutées par la modification (added_lines) | [
0 => 'local p = {}',
1 => 'local coord = require( "Module:Coordinates" )',
2 => '',
3 => 'local function normalise(args)',
4 => ' local lookup_table = {',
5 => ' ['largeur'] = 'width',',
6 => ' ['hauteur'] = 'height',',
7 => ' ['texte'] = 'text',',
8 => ' ['legende'] = 'text',',
9 => ' ['légende'] = 'text',',
10 => ' ['déscription'] = 'description',',
11 => ' ['titre'] = 'title',',
12 => ' ['sans_cadre'] = 'frameless',',
13 => ' ['symbole'] = 'symbol',',
14 => ' ['couleur'] = 'color',',
15 => ' ['taille'] = 'size',',
16 => ' ['epaisseur'] = 'size',',
17 => ' ['épaisseur'] = 'size',',
18 => ' ['opacite'] = 'opacity',',
19 => ' ['opacité'] = 'opacity',',
20 => ' ['epaisseur contour'] = 'outline_size',',
21 => ' ['épaisseur contour'] = 'outline_size',',
22 => ' ['couleur contour'] = 'outline_color',',
23 => ' ['opacite contour'] = 'opacity',',
24 => ' ['opacité contour'] = 'opacity',',
25 => ' ['couleur fond'] = 'fill_color',',
26 => ' ['opacite fond'] = 'fill_opacity',',
27 => ' ['opacité fond'] = 'fill_opacity',',
28 => ' ['geoline'] = 'contour',',
29 => ' ['requête'] = 'query',',
30 => ' ['requete'] = 'query',',
31 => ' ['request'] = 'query',',
32 => ' ['langue'] = 'lang',',
33 => ' }',
34 => ' ',
35 => ' for k, v in pairs(lookup_table) do',
36 => ' if args[k] ~= nil then',
37 => ' args[v] = args[k]',
38 => ' end',
39 => ' end',
40 => ' ',
41 => ' return args',
42 => 'end',
43 => '',
44 => 'local function decodeJsonList(value)',
45 => ' --[[ Plusieurs modèles, dont {{Carte interactive/Marqueur}}, ajoutent des',
46 => ' virgules à la fin des représentations JSON des objets. Cela fonctionne avec',
47 => ' le parsing JSON relaxé de HHVM, mais pas PHP7. Ce bug est détaillé ici:',
48 => ' https://phabricator.wikimedia.org/T214984',
49 => ' Cette fonction retire donc les virgules finales et initiales, avant',
50 => ' d'appeler mw.text.jsonDecode sur la liste.',
51 => ' ]]',
52 => ' local trimmedValue = mw.text.trim(value, ',')',
53 => ' return mw.text.jsonDecode('[' .. trimmedValue .. ']')',
54 => 'end',
55 => '',
56 => 'function p.marker(frame)',
57 => ' local args = normalise(frame:getParent().args)',
58 => ' ',
59 => ' if args[1] == nil and args.latlng == nil then --One coordinate is mandatory',
60 => ' return',
61 => ' end',
62 => ' ',
63 => ' local properties = {',
64 => ' ['marker-color'] = args.color == nil and '#555555' or args.color,',
65 => ' ['marker-size'] = args.size == nil and 'medium' or args.size,',
66 => ' ['marker-symbol'] = args.symbol == nil and '' or args.symbol,',
67 => ' ['title'] = args.title == nil and '' or args.title,',
68 => ' ['description'] = args.description == nil and '' or args.description,',
69 => ' }',
70 => ' ',
71 => ' local latlng = mw.text.split( (args[1] == nil and args.latlng or args[1]), ",", true )',
72 => ' ',
73 => ' if args.randomise ~= nil then',
74 => ' latlng[1] = latlng[1] + math.random(-tonumber(args.randomise), tonumber(args.randomise))/100000',
75 => ' latlng[2] = latlng[2] + math.random(-tonumber(args.randomise), tonumber(args.randomise))/100000',
76 => ' end',
77 => ' ',
78 => ' local geojson = {',
79 => ' type = "Feature",',
80 => ' properties = properties,',
81 => ' geometry = {',
82 => ' type = "Point",',
83 => ' coordinates = {',
84 => ' tonumber(latlng[2]), ',
85 => ' tonumber(latlng[1]),',
86 => ' }',
87 => ' }',
88 => ' }',
89 => ' return mw.text.jsonEncode(geojson) .. ','',
90 => 'end',
91 => '',
92 => 'function p.line(frame)',
93 => ' local args = normalise(frame:getParent().args)',
94 => ' ',
95 => ' if args[2] == nil then --At least two coordinates are mandatory',
96 => ' return',
97 => ' end',
98 => ' ',
99 => ' local properties = {',
100 => ' ["stroke"] = args.color == nil and '#555555' or args.color,',
101 => ' ["stroke-width"] = args.size == nil and 2 or tonumber(args.size),',
102 => ' ["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),',
103 => ' ['title'] = args.title == nil and '' or args.title,',
104 => ' ['description'] = args.description == nil and '' or args.description,',
105 => ' }',
106 => ' ',
107 => ' local coordinates = {}',
108 => ' local i = 1',
109 => ' while args[i] ~= nil do',
110 => ' local latlng = mw.text.split( args[i], ",", true )',
111 => ' coordinates[i] = {',
112 => ' tonumber(latlng[2]), ',
113 => ' tonumber(latlng[1]),',
114 => ' }',
115 => ' i = i+1',
116 => ' end',
117 => ' ',
118 => ' local geojson = {',
119 => ' type = "Feature",',
120 => ' properties = properties,',
121 => ' geometry = {',
122 => ' type = "LineString",',
123 => ' coordinates = coordinates',
124 => ' }',
125 => ' }',
126 => ' return mw.text.jsonEncode(geojson) .. ','',
127 => 'end',
128 => '',
129 => 'function p.polygon(frame)',
130 => ' local args = normalise(frame:getParent().args)',
131 => ' ',
132 => ' if args[3] == nil then --At least three coordinates are mandatory',
133 => ' return',
134 => ' end',
135 => ' ',
136 => ' local properties = {',
137 => ' ["stroke"] = args.color == nil and '#555555' or args.color,',
138 => ' ["stroke-width"] = args.size == nil and 2 or tonumber(args.size),',
139 => ' ["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),',
140 => ' ["fill"] = args.fill_color == nil and '#555555' or args.fill_color,',
141 => ' ["fill-opacity"] = args.fill_opacity == nil and 0.3 or tonumber(args.fill_opacity),',
142 => ' ['title'] = args.title == nil and '' or args.title,',
143 => ' ['description'] = args.description == nil and '' or args.description,',
144 => ' }',
145 => ' ',
146 => ' local coordinates = {}',
147 => ' local i = 1',
148 => ' while args[i] ~= nil do',
149 => ' local latlng = mw.text.split( args[i], ",", true )',
150 => ' coordinates[i] = {',
151 => ' tonumber(latlng[2]), ',
152 => ' tonumber(latlng[1]),',
153 => ' }',
154 => ' i = i+1',
155 => ' end',
156 => ' local latlng = mw.text.split( args[1], ",", true )',
157 => ' coordinates[i] = {',
158 => ' tonumber(latlng[2]), ',
159 => ' tonumber(latlng[1]),',
160 => ' }',
161 => ' ',
162 => ' local geojson = {',
163 => ' type = "Feature",',
164 => ' properties = properties,',
165 => ' geometry = {',
166 => ' type = "Polygon",',
167 => ' coordinates = { coordinates }',
168 => ' }',
169 => ' }',
170 => ' return mw.text.jsonEncode(geojson) .. ','',
171 => 'end',
172 => '',
173 => 'function p.query(frame)',
174 => ' local args = normalise(frame:getParent().args)',
175 => ' ',
176 => ' local query',
177 => ' if args[1] ~= nil then',
178 => ' query = args[1]',
179 => ' else',
180 => ' return',
181 => ' end',
182 => ' ',
183 => ' local properties = {',
184 => ' ["stroke"] = args.color == nil and '#555555' or args.color,',
185 => ' ["stroke-width"] = args.size == nil and 2 or tonumber(args.size),',
186 => ' ["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),',
187 => ' ["fill"] = args.fill_color == nil and '#555555' or args.fill_color,',
188 => ' ["fill-opacity"] = args.fill_opacity == nil and 0.3 or tonumber(args.fill_opacity),',
189 => ' ['title'] = args.title == nil and '' or args.title,',
190 => ' ['description'] = args.description == nil and '' or args.description,',
191 => ' }',
192 => ' ',
193 => ' local service = "geoshape"',
194 => ' if args.contour ~= nil then',
195 => ' service = "geoline"',
196 => ' end',
197 => ' ',
198 => ' local geojson = {',
199 => ' type = "ExternalData",',
200 => ' service = service,',
201 => ' query = query,',
202 => ' properties = properties,',
203 => ' }',
204 => ' return mw.text.jsonEncode(geojson) .. ','',
205 => 'end',
206 => '',
207 => 'function p.osm(frame)',
208 => ' local args = normalise(frame:getParent().args)',
209 => ' ',
210 => ' local qid',
211 => ' if args[1] == nil then',
212 => ' qid = mw.wikibase.getEntityIdForCurrentPage()',
213 => ' else',
214 => ' qid = mw.text.trim(args[1])',
215 => ' end',
216 => ' ',
217 => ' local properties = {',
218 => ' ["stroke"] = args.color == nil and '#555555' or args.color,',
219 => ' ["stroke-width"] = args.size == nil and 2 or tonumber(args.size),',
220 => ' ["stroke-opacity"] = args.opacity == nil and 1 or tonumber(args.opacity),',
221 => ' ["fill"] = args.fill_color == nil and '#555555' or args.fill_color,',
222 => ' ["fill-opacity"] = args.fill_opacity == nil and 0.3 or tonumber(args.fill_opacity),',
223 => ' ['title'] = args.title == nil and '' or args.title,',
224 => ' ['description'] = args.description == nil and '' or args.description,',
225 => ' }',
226 => ' ',
227 => ' local service = "geoshape"',
228 => ' if args.contour ~= nil then',
229 => ' service = "geoline"',
230 => ' end',
231 => ' ',
232 => ' local geojson = {',
233 => ' type = "ExternalData",',
234 => ' service = service,',
235 => ' ids = qid,',
236 => ' properties = properties,',
237 => ' }',
238 => ' return mw.text.jsonEncode(geojson) .. ','',
239 => 'end',
240 => '',
241 => 'function p.commons(frame)',
242 => ' local args = normalise(frame:getParent().args)',
243 => ' ',
244 => ' if args[1] == nil then',
245 => ' return',
246 => ' end',
247 => ' ',
248 => ' local page_name = args[1]',
249 => ' if mw.ustring.find(page_name, "Data:", 1, true) == 1 then',
250 => ' page_name = string.sub(page_name, 6)',
251 => ' end',
252 => ' if mw.ustring.find(page_name, ".map", -4, true) == nil then',
253 => ' page_name = page_name .. '.map'',
254 => ' end',
255 => ' ',
256 => ' local geojson = {',
257 => ' type = "ExternalData",',
258 => ' service = "page",',
259 => ' title = page_name',
260 => ' }',
261 => ' return mw.text.jsonEncode(geojson) .. ','',
262 => 'end',
263 => '',
264 => 'function p.wikidata(frame)',
265 => ' local args = normalise(frame:getParent().args)',
266 => ' local qid',
267 => ' ',
268 => ' local properties = {',
269 => ' ['marker-color'] = args.color == nil and '#555555' or args.color,',
270 => ' ['marker-size'] = args.size == nil and 'medium' or args.size,',
271 => ' ['marker-symbol'] = args.symbol == nil and '' or args.symbol,',
272 => ' ['title'] = args.title == nil and '' or args.title,',
273 => ' ['description'] = args.description == nil and '' or args.description,',
274 => ' }',
275 => ' ',
276 => ' if args[1] == nil then',
277 => ' qid = mw.wikibase.getEntityIdForCurrentPage()',
278 => ' else',
279 => ' qid = args[1]',
280 => ' end',
281 => ' ',
282 => ' local entity = mw.wikibase.getEntity( qid )',
283 => ' local value = entity:formatPropertyValues( 'P625', { mw.wikibase.entity.claimRanks.RANK_NORMAL, mw.wikibase.entity.claimRanks.RANK_PREFERRED, mw.wikibase.entity.claimRanks.RANK_TRUTH } ).value',
284 => ' if value == nil then',
285 => ' error('La propriété P625 "coordonnées géographiques" n\'est pas renseigné sur Wikidata')',
286 => ' end',
287 => ' latlng = mw.text.split( mw.text.decode(value), ", ", true )',
288 => ' geojson = {',
289 => ' type = "Feature",',
290 => ' geometry = {',
291 => ' type = "Point",',
292 => ' coordinates = {',
293 => ' coord._dms2dec(coord._parsedmsstring(latlng[2])), ',
294 => ' coord._dms2dec(coord._parsedmsstring(latlng[1]))',
295 => ' }',
296 => ' },',
297 => ' properties = properties',
298 => ' }',
299 => ' ',
300 => ' return mw.text.jsonEncode(geojson) .. ','',
301 => 'end',
302 => '',
303 => 'function p.tag(frame)',
304 => ' local args = ( frame.getParent and normalise(frame:getParent().args) ) or frame',
305 => ' ',
306 => ' -- Choose the tagname',
307 => ' local tagname = 'mapframe'',
308 => ' if args.lien ~= nil then',
309 => ' tagname = 'maplink'',
310 => ' end',
311 => '',
312 => ' -- Manage the basics tag params',
313 => ' local tagArgs = {',
314 => ' zoom = args.zoom == nil and args.commons == nil and 14 or tonumber(args.zoom),',
315 => ' height = args.height == nil and 420 or tonumber(args.height),',
316 => ' width = args.width == nil and 420 or tonumber(args.width),',
317 => ' align = args.align == nil and 'right' or args.align,',
318 => ' text = args.text,',
319 => ' }',
320 => ' ',
321 => ' if args[1] ~= nil and (args.latitude ~= nil or args.longitude ~= nil) then',
322 => ' error('La ou les valeurs de longitude et/ou de latitude ont été fournis via deux syntaxe différentes. Consultez la documentation du [[Modèle:Carte interactive]] pour obtenir une syntaxe correcte')',
323 => ' elseif args.latitude ~= nil and args.latitude ~= ''',
324 => ' and args.longitude ~= nil and args.longitude ~= '' then',
325 => ' tagArgs.latitude = args.latitude',
326 => ' tagArgs.longitude = args.longitude',
327 => ' elseif args[1] ~= nil and args[2] ~= nil then',
328 => ' tagArgs.latitude = args[1]',
329 => ' tagArgs.longitude = args[2]',
330 => ' elseif args.commons == nil and args.wikidata == nil',
331 => ' and args.formes == nil and args.query == nil and args.externes == nil then --The only exceptions allowed to put latitude and longitude away are when using an external map stored on commons, coord from wikidata, formes, query or externes',
332 => ' error('Les paramètres de latitude et/ou de longitude sont absent')',
333 => ' end',
334 => ' ',
335 => ' if tagArgs.latitude ~= nil and tagArgs.longitude ~= nil then',
336 => ' if tonumber(tagArgs.latitude) then',
337 => ' tagArgs.latitude = tonumber(tagArgs.latitude)',
338 => ' else',
339 => ' tagArgs.latitude = coord._dms2dec(coord._parsedmsstring(tagArgs.latitude))',
340 => ' end',
341 => ' if tonumber(tagArgs.longitude) then',
342 => ' tagArgs.longitude = tonumber(tagArgs.longitude)',
343 => ' else',
344 => ' tagArgs.longitude = coord._dms2dec(coord._parsedmsstring(tagArgs.longitude))',
345 => ' end',
346 => ' end',
347 => '',
348 => ' if args.frameless then',
349 => ' tagArgs.frameless = ''',
350 => ' end',
351 => ' ',
352 => ' if args.lang ~= nil then',
353 => ' tagArgs.lang = args.lang',
354 => ' end',
355 => ' ',
356 => ' -- Manage the basics GeoJSON params',
357 => ' local geojson = {}',
358 => ' ',
359 => ' if args.commons ~= nil then',
360 => ' geojson[#geojson+1] = {',
361 => ' type = "ExternalData",',
362 => ' service = "page",',
363 => ' title = args.commons,',
364 => ' }',
365 => ' end',
366 => ' ',
367 => ' if args.marqueur ~= nil and args.marqueur ~= '' then',
368 => ' geojson[#geojson+1] = {',
369 => ' type = "Feature",',
370 => ' geometry = {',
371 => ' type = "Point",',
372 => ' coordinates = {',
373 => ' tagArgs.longitude, ',
374 => ' tagArgs.latitude',
375 => ' }',
376 => ' },',
377 => ' properties = {',
378 => ' ['marker-color'] = (args.color == nil or args.color == '') and '#555555' or args.color,',
379 => ' ['marker-size'] = (args.size == nil or args.size == '') and 'medium' or args.size,',
380 => ' ['marker-symbol'] = args.symbol == nil and '' or args.symbol,',
381 => ' ['title'] = args.title == nil and '' or args.title,',
382 => ' ['description'] = args.description == nil and '' or args.description,',
383 => ' }',
384 => ' }',
385 => ' end',
386 => ' ',
387 => ' if args.osm ~= nil and args.osm ~= '' then',
388 => ' local qid',
389 => ' if args.osm == 'oui' then',
390 => ' qid = mw.wikibase.getEntityIdForCurrentPage()',
391 => ' if qid == nil then',
392 => ' qid = "Q1"',
393 => ' end',
394 => ' else',
395 => ' qid = args.osm',
396 => ' end',
397 => ' ',
398 => ' local service = "geoshape"',
399 => ' if args.contour ~= nil then',
400 => ' service = "geoline"',
401 => ' end',
402 => ' ',
403 => ' geojson[#geojson+1] = {',
404 => ' type = "ExternalData",',
405 => ' service = service,',
406 => ' ids = qid,',
407 => ' properties = {',
408 => ' ['title'] = args.title == nil and '' or args.title,',
409 => ' ['description'] = args.description == nil and '' or args.description,',
410 => ' ['stroke'] = args.outline_color == nil and '#555555' or args.outline_color,',
411 => ' ['stroke-width'] = args.outline_size == nil and 2 or tonumber(args.outline_size),',
412 => ' }',
413 => ' }',
414 => ' end',
415 => ' ',
416 => ' local qid = args.wikidata',
417 => ' if qid and not mw.wikibase.isValidEntityId( qid ) then',
418 => ' qid = mw.wikibase.getEntityIdForCurrentPage()',
419 => ' end',
420 => ' if qid and mw.wikibase.isValidEntityId( qid ) then',
421 => ' local entity = mw.wikibase.getEntity( qid )',
422 => ' local value = entity:formatPropertyValues( 'P625', { mw.wikibase.entity.claimRanks.RANK_NORMAL, mw.wikibase.entity.claimRanks.RANK_PREFERRED, mw.wikibase.entity.claimRanks.RANK_TRUTH } ).value',
423 => ' if value == '' then',
424 => ' error('La propriété P625 "coordonnées géographiques" n\'est pas renseigné sur Wikidata')',
425 => ' end',
426 => ' latlng = mw.text.split( mw.text.decode(value), ", ", true )',
427 => ' geojson[#geojson+1] = {',
428 => ' type = "Feature",',
429 => ' geometry = {',
430 => ' type = "Point",',
431 => ' coordinates = {',
432 => ' coord._dms2dec(coord._parsedmsstring(latlng[2])), ',
433 => ' coord._dms2dec(coord._parsedmsstring(latlng[1]))',
434 => ' }',
435 => ' },',
436 => ' properties = {',
437 => ' title = args.title == nil and '' or args.title,',
438 => ' description = args.description == nil and '' or args.description,',
439 => ' }',
440 => ' }',
441 => ' end',
442 => ' ',
443 => ' if args.query ~= nil then',
444 => ' local service = "geoshape"',
445 => ' if args.contour ~= nil then',
446 => ' service = "geoline"',
447 => ' end',
448 => ' ',
449 => ' geojson[#geojson+1] = {',
450 => ' type = "ExternalData",',
451 => ' service = service,',
452 => ' query = args.query,',
453 => ' properties = {',
454 => ' title = args.title == nil and '' or args.title,',
455 => ' description = args.description == nil and '' or args.description,',
456 => ' }',
457 => ' }',
458 => ' end',
459 => ' ',
460 => ' --Manage external GeoJSON datas included through models',
461 => ' if args.formes ~= nil then',
462 => ' geojson[#geojson+1] = {',
463 => ' type = "FeatureCollection",',
464 => ' features = decodeJsonList(args.formes)',
465 => ' }',
466 => ' end',
467 => ' ',
468 => ' if args.externes ~= nil and args.externes ~= '' then',
469 => ' local externes = decodeJsonList(args.externes)',
470 => ' for k, externe in pairs(externes) do',
471 => ' geojson[#geojson+1] = externe',
472 => ' end',
473 => ' end',
474 => ' ',
475 => ' return frame:extensionTag(tagname, mw.text.jsonEncode(geojson), tagArgs)',
476 => 'end',
477 => '',
478 => 'return'
] |