Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
Reverted to revision 623263051 by Jackmcbarn (talk). (TW)
Jackmcbarn (talk | contribs)
add lambertConformalConic function
Line 1:
local p = {}
 
function p.lambertConformalConic(refLat, refLong, stdParallel1, stdParallel2)
return function(latitude, longitude)
local n
if stdParallel1 == stdParallel2 then
n = math.sin(stdParallel1)
else
n = math.log(math.cos(stdParallel1)/math.cos(stdParallel2))/
math.log(math.tan(0.25*math.pi + 0.5*stdParallel2)/math.tan(0.25*math.pi + 0.5*stdParallel1))
end
local f = math.cos(stdParallel1)*math.tan(0.25*math.pi + 0.5*stdParallel1)^n/n
local rho = f*math.tan(0.25*math.pi + 0.5*latitude)^-n
local rho0 = f*math.tan(0.25*math.pi + 0.5*refLat)^-n
return {
x = rho*math.sin(n*(longitude - refLong)),
y = rho0 - rho*math.cos(n*(longitude - refLong))
}
end
end
 
function p.main(frame)