Content deleted Content added
tweak? |
atan2 doesn't work and fix other bugs |
||
Line 510:
local phi = deg2rad ( latitude )
local lambda = deg2rad ( longitude )
local cosphi = cos ( phi )
local sinphi = sin ( phi )
Line 524 ⟶ 523:
local y1 = ny * cosphi * sinlambda
local z1 = ny * ( 1. - e1 ) * sinphi
-- the helmert transformation proper
-- Equation 3, Section 6.2, Ordnance Survey document
Line 531 ⟶ 529:
local y2 = ty + ( rz * x1 + s0 * y1 - rx * z1 )
local z2 = tz + ( -ry *x1 + rx * y1 + s0 * z1 )
-- convert cartesian coordinates to latitude and longitude
-- math in Annex B.2, of Ordnance Survey document
Line 538 ⟶ 535:
local e2 = ( aq - b2 * b2 ) / aq
lambda = atan ( y2
local p2 = sqrt ( x2*x2 + y2*y2 )
phi = atan ( z2
local limit = 1. / b2
Line 550 ⟶ 547:
phi_alt = phi
ny = a2 / sqrt ( 1. - e2 * sin(phi) * sin(phi) )
phi = atan ( (z2 + e2 * ny * sin(phi))
n0 = n0 - 1
until abs ( phi - phi_alt ) <= limit or n0 <= 0
Line 595 ⟶ 592:
local T = pow( tan(lat_rad), 2)
local C = e_prime_sq * pow( cos(lat_rad), 2)
local A = deg2rad( longitude2 -
local M = find_M( lat_rad )
local M0 = 0.0
if latitude_origin ~= 0 then
M0 = find_M(deg2rad(
end
Line 624 ⟶ 621:
local function LatLon2OSGB36( latlon )
local tm = LatLonOrigin2TM(latlon.lat, latlon.lon)
if not tm then return '
-- fix by Roger W Haworth
Line 634 ⟶ 631:
local letters = "ABCDEFGHJKLMNOPQRSTUVWXYZ"
local
local
local c1 = mw.ustring.sub(letters,indx1,indx1)
local c2 = mw.ustring.sub(letters,indx2,indx2)
local e = mw.ustring.format('%05d', tm.easting%100000)
Line 650 ⟶ 649:
function oscoord.WGS2OSGB(frame)
local args = getArgs(frame)
return args[1]
end
|