Content deleted Content added
start on inverse code |
more |
||
Line 54:
local wgs84radius = 6378137.0
local wgs84ecc = 0.00669438003551279089034150031998869922791
local
local eastingGB = 400000.0
local northingGB = -100000.0
local lat0GB = 49.0
local lon0GB = -2.0
local Airyradius = 6377563.396
local Airyecc = 0.006670539761597529073698869358812557054558
local function northeast(lett,num,shift)
Line 92 ⟶ 98:
local function GBEN2LL(e,n)
-- True Origin is 2 deg W
local phi0uk=
-- True Origin is 49 deg N
local lambda0uk=
-- scale factor @ central meridian
local F0uk=
-- True origin in 400 km E of false origin
local E0uk=
--True origin is 100 km S of false origin
local N0uk=
-- semi-major axis (in line to equator) 0.996012717 is yer scale @ central meridian
local auk=
--semi-minor axis (in line to poles)
local buk=6356256.91*F0uk
Line 108 ⟶ 114:
local n1uk=0.00167322025032508731869331280635710896296
-- first eccentricity squared=2*f-f^2where f=(a1-b1)/a1
local e2uk=
local k=(n-N0uk)/auk+lambda0uk/dr
local nextcounter=0
Line 138 ⟶ 144:
local long=phi0uk+dr*(y1*j6-y1*y1*y1*j7+pow(y1,5.0)*j8-pow(y1,7.0)*j9)
local lat=k9*dr
local v=
local cartxa=v*cos(k9)*cos(long/dr)
local cartya=v*cos(k9)*sin(long/dr)
Line 486 ⟶ 492:
local b1 = 6356752.3141
local a2 =
local b2 = 6356256.910
Line 551 ⟶ 557:
end
--[[
* Convert latitude, longitude in decimal degrees to
* OSBG36 Easting and Northing
]]
local function LatLon2OSGB36( latlon )
local latitude = latlon.lat
local longitude = latlon.lon
-- Airy 1830 ellipsoid
local radius = Airyradius
-- inverse flattening 1/f: 299.3249647
local eccentricity = Airyecc -- square of eccentricity
local scale = scaleGB
local easting_offset = eastingGB
local northing_offset = northingGB
local latitude_origin = lat0GB
local longitude_origin = lon0GB
local tm = LatLonOrigin2TM(latitude, longitude, latitude_origin, longitude_origin)
if not tm then return '' end
-- fix by Roger W Haworth
local grid_x = floor( tm.easting / 100000 )
local grid_y = floor( tm.northing / 100000 )
if grid_x < 0 or grid_x > 6 or grid_y < 0 or grid_y > 12 then return '' end
-- 0000000001111111111222222
-- 1234567890123456789012345
local letters = "ABCDEFGHJKLMNOPQRSTUVWXYZ"
local c1 = mw.ustring.sub(letters,18-floor(grid_y/5)*5+floor(grid_x/5),1)
local c2 = mw.ustring.sub(letters,21-(grid_y%5)*5+grid_x%5,1)
local e = mw.ustring.format('%05d', tm.easting%100000)
local n = mw.ustring.format('%05d', tm.northing%100000)
return c1..c2..e..n
end
function oscoord.WGS2OSGB(lat,lon)
return LatLong2OSGB(HelmertDatumShift(lat,lon))
end
return oscoord
|