« Module:Carte » : différence entre les versions
Aucun résumé des modifications |
support pour "Projection conique équidistante", réglage taille de point sur Chrome |
||
Ligne 4 : | Ligne 4 : | ||
local linguistic = require('Module:Linguistique') | local linguistic = require('Module:Linguistique') | ||
local function | -- 'Projection conique avec DL' | ||
local function dllat(latitude, longitude, mapdata) -- conique avec DL | |||
local val = 100* | local val = 100* | ||
(mapdata.y0 + | (mapdata.y0 + | ||
Ligne 17 : | Ligne 18 : | ||
return val | return val | ||
end | end | ||
local function | local function dllong(latitude, longitude, mapdata) | ||
local val = 100 * ( | local val = 100 * ( | ||
( (mapdata.x0 or (mapdata.iwidth/2)) + | ( (mapdata.x0 or (mapdata.iwidth/2)) + | ||
Ligne 33 : | Ligne 34 : | ||
return val | return val | ||
end | end | ||
-- 'Projection conique équidistante' | |||
local function equilat(latitude, longitude, mapdata) | |||
local val = | |||
100/(mapdata.top-mapdata.bottom) * | |||
( | |||
mapdata.top-(mapdata.latitudeG or 90)) + | |||
(mapdata.latitudeG or 90 -latitude)* | |||
math.cos( | |||
matdata.n or math.sin((mapdata.latitude or ((mapdata.top + mapdata.bottom)/2) ) * math.pi / 180) | |||
* math.pi/180 *(longitude-(mapdata.longitude) | |||
) | |||
) | |||
return val | |||
end | |||
local function equilong(latitude, longitude, mapdata) | |||
local val = | |||
100*(( mapdata.px0 or 50 )/100 + | |||
(mapdata.dx or 1) / (mapdata.aspectRatio or 1 ) / | |||
(mapdata.top-mapdata.bottom)*((mapdata.latitudeG or 90) -mapdata.latitude)* | |||
math.sin( | |||
(mapdata.n or sin(( latitude or (mapdata.top + mapdata.bottom )/2)*math.pi/180)) | |||
* math.pi/180 *(longitude-(mapdata.longitude)) ) | |||
) | |||
return val | |||
end | |||
---------------------------------- | |||
local function buildmap(map, maptype, width, latitude, longitude, pointtype, caption) -- fonction d'aige pour buildmap | local function buildmap(map, maptype, width, latitude, longitude, pointtype, caption) -- fonction d'aige pour buildmap | ||
Ligne 53 : | Ligne 82 : | ||
-- analyse linguistique pour le texte de la carte | -- analyse linguistique pour le texte de la carte | ||
local datagender = mapdata.genre or '' | local datagender = mapdata.genre or '' | ||
local gender = string.sub(datagender, 1, 1) -- | local gender = string.sub(datagender, 1, 1) -- ms = masculin-singulier, fp = féminin pluriel etc. | ||
local number = string.sub(datagender, 2, 2) | local number = string.sub(datagender, 2, 2) | ||
local determiner = mapdata.determiner | local determiner = mapdata.determiner | ||
Ligne 66 : | Ligne 95 : | ||
pointheight = coniclat(latitude, longitude, mapdata) | pointheight = coniclat(latitude, longitude, mapdata) | ||
pointwidth = coniclong(latitude, longitude, mapdata) | pointwidth = coniclong(latitude, longitude, mapdata) | ||
elseif mapdata.projection == 'Projection conique avec DL' then | |||
pointheight = coniclat(latitude, longitude, mapdata) | |||
pointwidth = coniclong(latitude, longitude, mapdata) | |||
else | else | ||
return "système cartographique non supporté" | return "système cartographique non supporté" | ||
Ligne 78 : | Ligne 110 : | ||
:css{position = 'absolute', border = 'none', top = htmlheight, left = htmlwidth} | :css{position = 'absolute', border = 'none', top = htmlheight, left = htmlwidth} | ||
:tag('div') | :tag('div') | ||
:css{position = 'absolute', top = '-4px', left = '-4px', ['line-height'] = '0'} | :css{position = 'absolute', top = '-4px', left = '-4px', ['line-height'] = '0', width = '8px'} | ||
:wikitext('[[Image:' .. pointimage .. ' | :wikitext('[[Image:' .. pointimage .. ']]') | ||
:done() | :done() | ||
local mapname = mapdata.name | local mapname = mapdata.name |
Version du 18 décembre 2014 à 18:01
local p = {} local mapdatamod = require('Module:Données cartes') local pointmod = require('Module:Carte/Points') local linguistic = require('Module:Linguistique')
-- 'Projection conique avec DL' local function dllat(latitude, longitude, mapdata) -- conique avec DL local val = 100* (mapdata.y0 + ( mapdata.iheight/2 - mapdata.y0 ) * (1 - mapdata.t * (latitude - mapdata.centrallat) * (0.01745329252 + 0.00000177219231 * (latitude - mapdata.centrallat) ^2) )* ( 1- 0.00015230871 * (longitude-mapdata.centrallong) ^2 * mapdata.s^2) ) / mapdata.iheight
return val end local function dllong(latitude, longitude, mapdata) local val = 100 * ( ( (mapdata.x0 or (mapdata.iwidth/2)) + ( mapdata.iheight/2 - mapdata.y0 ) * ( 1 -mapdata.t * (latitude-mapdata.centrallat) * ( 0.01745329252 + 0.00000177219231 * (latitude-mapdata.centrallat) * (latitude-mapdata.centrallat) ) ) * (longitude-mapdata.centrallong) * mapdata.s * (0.01745329252 - 0.000000886096156 * (longitude-(mapdata.centrallong)) * (longitude-(mapdata.centrallong)) * mapdata.s^2 ) ) ) / mapdata.iwidth return val end
-- 'Projection conique équidistante' local function equilat(latitude, longitude, mapdata) local val = 100/(mapdata.top-mapdata.bottom) * ( mapdata.top-(mapdata.latitudeG or 90)) +
(mapdata.latitudeG or 90 -latitude)* math.cos(
matdata.n or math.sin((mapdata.latitude or ((mapdata.top + mapdata.bottom)/2) ) * math.pi / 180) * math.pi/180 *(longitude-(mapdata.longitude)
) )
return val end
local function equilong(latitude, longitude, mapdata) local val = 100*(( mapdata.px0 or 50 )/100 + (mapdata.dx or 1) / (mapdata.aspectRatio or 1 ) / (mapdata.top-mapdata.bottom)*((mapdata.latitudeG or 90) -mapdata.latitude)* math.sin( (mapdata.n or sin(( latitude or (mapdata.top + mapdata.bottom )/2)*math.pi/180)) * math.pi/180 *(longitude-(mapdata.longitude)) ) ) return val end
local function buildmap(map, maptype, width, latitude, longitude, pointtype, caption) -- fonction d'aige pour buildmap if map == '-' then return end local mapdata = mapdatamod.main(map) if not mapdata or not mapdata.images then addmaintenancecat('Page avec des données de géolocalisation non supportées') return "carte non supportée: " .. map end local name = mapdata.name or '?'
if (not pointtype) then pointtype = default end pointimage = pointmod[pointtype] if not pointimage then pointimage = pointmod.default end -- + message d'erreur ?
-- analyse linguistique pour le texte de la carte local datagender = mapdata.genre or local gender = string.sub(datagender, 1, 1) -- ms = masculin-singulier, fp = féminin pluriel etc. local number = string.sub(datagender, 2, 2) local determiner = mapdata.determiner local ofstring = linguistic.of(name, gender, number, determiner) -- restitue "de France" ou "du Japon"
local pointsize = tostring(8) local pointheight, pointwidth if mapdata.projection == 'Projection équirectangulaire' then pointheight = 100 * (latitude - mapdata.top) / (mapdata.bottom - mapdata.top) pointwidth = 100 * (longitude - mapdata.left) / (mapdata.right - mapdata.left) elseif mapdata.projection == 'Projection conique avec DL' then pointheight = coniclat(latitude, longitude, mapdata) pointwidth = coniclong(latitude, longitude, mapdata) elseif mapdata.projection == 'Projection conique avec DL' then pointheight = coniclat(latitude, longitude, mapdata) pointwidth = coniclong(latitude, longitude, mapdata) else return "système cartographique non supporté" end if (pointheight > 100) or (pointwidth) > 100 or (pointheight < 0) or (pointwidth < 0) then return end local htmlheight = tostring(pointheight) .. '%' local htmlwidth = tostring(pointwidth) .. '%'
local pointdiv = mw.html.create('div') :css{position = 'absolute', border = 'none', top = htmlheight, left = htmlwidth} :tag('div') :css{position = 'absolute', top = '-4px', left = '-4px', ['line-height'] = '0', width = '8px'} :wikitext('Fichier:' .. pointimage .. '') :done() local mapname = mapdata.name local file if type(mapdata.images) == 'string' then file = mapdata.images else file = mapdata.images[maptype] or mapdata.images[1] or mapdata.images['default'] end local alt = 'voir sur la carte ' .. ofstring local map = mw.html.create('div') :css{['text-align'] = 'center'} :addClass("geobox") :wikitext('Géolocalisation sur la carte ' .. ofstring .. '') :tag('table') :addClass('DebutCarte') :attr({border="0", cellspacing="0", cellpadding="0"}) :css({margin = '0', border = 'none', padding = '0'}) :tag('tr') :tag('td') :tag('div') :css({position= 'relative', margin = "auto",}) :wikitext('' .. alt .. '' ) :node(pointdiv) :done() :done() :done() :done() return map end
function p.multimap(params) local maplist = params.maplist local width = params.width local latitude = params.latitude local longitude = params.longitude
-- les cartes s'affichent en ordre inversé, remettre bien local newlist = {} for i, j in pairs(maplist) do table.insert(newlist, 1, j) end maplist = newlist
-- traitement de la largeur if width and tonumber(width) then width = tonumber(width) else width = 280 end-- si pas un nombre, erreur ? local div = mw.html.create('div'):addClass('img_toogle')
if not pointimage then pointimage = 'Point carte.svg' end
--transition: appel aux Modèle:Géolocalisation/ n en l'absence de données dans le module
local mapliststring = table.concat(maplist, '/')
for i, j in pairs(maplist) do if not require('Module:Données cartes').main(j) then return mw.getCurrentFrame():expandTemplate{ title = 'Infobox/Géolocalisation multiple/transition', args = {['géolocalisation'] = mapliststring, type = maptype, latitude = latitude, longitude = longitude }} .. end end for i, map in pairs(maplist) do local newmap = buildmap( map, maptype, width, latitude, longitude, pointimage, caption) div:node(newmap) end return div end
function p.map(frame) local args = frame.args -- utilisation du franaçs args.maplist = mw.text.split( args.carte, '/', true) return p.multimap(args) end return p