Module:Austrianmap
Apparence
La documentation de ce module est générée par le modèle {{Documentation module}}.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local Tools = require('Module:Outils')
local Coordinates = require('Module:Coordinates')
local wd = require("Module:Wikidata")
local url = {}
local function coord_converter(value)
if tonumber(value) then
return value
else
local dms_object = Coordinates._parsedmsstring(value)
return Coordinates._dms2dec(dms_object)
end
end
local function coord(args)
if args.latitude and args.longitude then
local latitude = coord_converter(args.latitude)
local longitude = coord_converter(args.longitude)
return latitude, longitude
else
local claim = wd.getClaims({property = 'P625'})
if claim then
local coords = wd.formatSnak(claim[1].mainsnak)
return coords.latitude, coords.longitude
else
return 0, 0
end
end
end
local function set_zoom(zoom, lon)
local pi = 3.141592653589793
if not tonumber(zoom) then
zoom = 3
end
if tonumber(zoom) > 5 then
zoom = 5
elseif tonumber(zoom) < 1 then
zoom = 1
end
local lon1 = lon - pi/(1000*zoom)
local lon2 = lon + pi/(1000*zoom)
return lon1, lon2
end
url.austrianmap = function (frame)
local args = Tools.extractArgs(frame)
local validArg = function ( ... ) return Tools.validTextArg( args, ... ) end
local latitude, longitude = coord(args)
local desc = args.desc or 'Visualisation'
local pi = 3.141592653589793
local e = 0.08181919132
local a = 6378137
local lat = latitude * pi / 180
local lon = longitude * pi / 180
local lat_1 = 49 * pi / 180
local lat_2 = 46 * pi / 180
local lat_0 = 47.5 * pi / 180
local lon_0 = 13.33333333 * pi / 180
local x_0 = 400000
local y_0 = 400000
zoom = args.zoom or 3
local lon1, lon2 = set_zoom(zoom, lon)
local n_num = math.log(math.cos(lat_2)/math.cos(lat_1)) + 0.5*math.log((1-e^2*math.sin(lat_1)^2)/(1-e^2*math.sin(lat_2)^2))
local n_dem = math.log( math.tan(pi/4+lat_1/2)*(1-e*math.sin(lat_1))^(e/2)*(1+e*math.sin(lat_2))^(e/2) / (math.tan(pi/4+lat_2/2)*(1+e*math.sin(lat_1))^(e/2)*(1-e*math.sin(lat_2))^(e/2)) )
local n = n_num / n_dem
local init = a*math.cos(lat_1)/(n*math.sqrt(1-e^2*math.sin(lat_1)^2)) * ((math.tan(pi/4+lat_1/2))*((1-e*math.sin(lat_1))/(1+e*math.sin(lat_1)))^(e/2))^n
local rho = init * ((1/math.tan(pi/4+lat/2))*((1+e*math.sin(lat))/(1-e*math.sin(lat)))^(e/2))^n
local rho_0 = init * ((1/math.tan(pi/4+lat_0/2))*((1+e*math.sin(lat_0))/(1-e*math.sin(lat_0)))^(e/2))^n
--local X = math.floor(x_0 + rho * math.sin(n * (lon - lon_0)))
--local Y = math.floor(y_0 + rho_0 - rho * math.cos(n * (lon - lon_0)))
local X1 = math.floor(x_0 + rho * math.sin(n * (lon1 - lon_0)))
local Y1 = math.floor(y_0 + rho_0 - rho * math.cos(n * (lon1 - lon_0)))
local X2 = math.floor(x_0 + rho * math.sin(n * (lon2 - lon_0)))
local Y2 = math.floor(y_0 + rho_0 - rho * math.cos(n * (lon2 - lon_0)))
local header = '[http://www.austrianmap.at/amap/index.php?setTo=1~'
local url_coord = X1 .. '~' .. Y1 .. '~' .. X2 .. '~' .. Y2
url = header .. url_coord .. ' ' .. desc ..'] sur [[Bundesamt für Eich- und Vermessungswesen|BEV]].'
if args['consulté le'] then
url = url .. ' <small>(consulté le' .. args['consulté le'] .. ')</small>'
end
if latitude == 0 and longitude == 0 then -- Pas de coordonnées entrées et pas de coordonnées wikidata
url = 'Coordonnées manquantes.'
end
return url
end
url.basemap = function (frame)
local args = Tools.extractArgs(frame)
local validArg = function ( ... ) return Tools.validTextArg( args, ... ) end
local latitude, longitude = coord(args)
local zoom = args.zoom or 13
local desc = args.desc or 'Visualisation'
local pi = 3.141592653589793
local a = 6378137
local lat = latitude * pi / 180
local lon = longitude * pi / 180
local X = math.floor(a * lon )
local Y = math.floor(a*0.5*math.log((1+math.sin(lat))/(1-math.sin(lat))))
local header = '[https://www.basemap.at/application/index.html#{%22center%22:'
local url_coord = '%5B' .. X .. ',' .. Y .. '%5D'
local url = header .. url_coord .. ',%22zoom%22:' .. zoom .. ',%22rotation%22:0,%22layers%22:%22010000000000%22} ' .. desc .. '] sur Basemap.'
if args['consulté le'] then
url = url .. ' <small>(consulté le' .. args['consulté le'] .. ')</small>'
end
if latitude == 0 and longitude == 0 then -- Pas de coordonnées entrées et pas de coordonnées wikidata
url = 'Coordonnées manquantes.'
end
return url
end
url.vogis = function (frame)
local args = Tools.extractArgs(frame)
local validArg = function ( ... ) return Tools.validTextArg( args, ... ) end
local latitude, longitude = coord(args)
local desc = args.desc or 'Visualisation'
local pi = 3.141592653589793
local zoom = args.zoom or 2
local dy = 0.011*zoom
local dx = dy*math.cos(latitude)
local url_coord = (longitude-dx) .. ',' .. (latitude+dy) .. ',' .. (longitude+dx) .. ',' .. (latitude-dy)
local header = '[http://vogis.cnv.at/atlas/init.aspx?karte=adressen_u_ortsplan&box='
local url = header .. url_coord .. '&srs=4326 ' .. desc .. '] sur [https://Vorarlberg.at Vorarlberg.at].'
if args['consulté le'] then
url = url .. ' <small>(consulté le' .. args['consulté le'] .. ')</small>'
end
if latitude == 0 and longitude == 0 then -- Pas de coordonnées entrées et pas de coordonnées wikidata
url = 'Coordonnées manquantes.'
end
return url
end
return url