Aller au contenu

Module:Austrianmap

Cette page fait l’objet d’une mesure de semi-protection étendue.
Une page de Wikipédia, l'encyclopédie libre.
Ceci est une version archivée de cette page, en date du 6 février 2021 à 13:18 et modifiée en dernier par Noritop (discuter | contributions) (Nouvelle page : local Outils = require( 'Module:Outils' ) local Coordinates = require( 'Module:Coordinates' ) local wd = require( "Module:Wikidata" ) local url = {} url.austrianmap = function (f…). Elle peut contenir des erreurs, des inexactitudes ou des contenus vandalisés non présents dans la version actuelle.
(diff) ← Version précédente | Version actuelle (diff) | Version suivante → (diff)

 Documentation[créer] [purger]
local Outils = require( 'Module:Outils' )
local Coordinates = require( 'Module:Coordinates' )
local wd = require( "Module:Wikidata" )
local url = {}

url.austrianmap = function (frame)
	local args = Outils.extractArgs(frame)
	local validArg = function ( ... ) return Outils.validTextArg( args, ... ) end
	
	local url = ''
	local desc = args.desc or 'Visualisation'
	
	local pi = 3.141592653589793
	local e = 0.08181919132
	local a = 6378137
	local lat = args.latitude * pi / 180
	local lon = args.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
	
	local lon1 = lon - pi/5000
	local lon2 = lon + pi/5000

	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 = 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
	
	return url
end

return url