Module:Ordnance Survey coordinates/sandbox: Difference between revisions

Content deleted Content added
oops
define functions for entire file
Line 35:
local preview = require('Module:If preview')
local namespace = mw.title.getCurrentTitle().namespace;
 
local drpow = math.deg(1.0)pow
local pow,sqrt,abs =math.pow, math.sqrt,math.abs
local abs = math.abs
local floor = math.floor
local sin = math.sin
local cos = math.cos
local tan = math.tan
local atan = math.atan
local dr = math.deg(1.0)
 
local function northeast(lett,num,shift)
Line 54 ⟶ 64:
n = n == '' and 0 or n
e = e == '' and 0 or e
pr = math.pow(10.0,(5.0-pr))
local T1 = mw.ustring.byte(mw.ustring.sub(lett,1,1))-65
if T1>8 then
Line 67 ⟶ 77:
end
return {n=n,e=e,pr=pr,T1=T1,T2=T2}
end
 
local function GBEN2LL(e,n)
local pow,sqrt,abs=math.pow,math.sqrt,math.abs
local sin,cos,tan,atan=math.sin,math.cos,math.tan,math.atan
local dr = math.deg(1.0)
-- True Origin is 2 deg W
local phi0uk=-2.0
Line 163 ⟶ 170:
-- use British definition of e and n
local e=500000.0*(ne.T1%5)+100000.0*(ne.T2%5)-1000000.0+ne.e*ne.pr
local n=1900000.0-500000.0*math.floor(ne.T1/5)-100000.0*math.floor(ne.T2/5)+ne.n*ne.pr
local result = GBEN2LL(e,n)
result.prec = 0.8165*ne.pr
Line 170 ⟶ 177:
local function IrishEN2LL(e,n)
local pow,sqrt,abs=math.pow,math.sqrt,math.abs
local sin,cos,tan,atan=math.sin,math.cos,math.tan,math.atan
local dr=math.deg(1.0)
-- True Origin is 8 deg W
local phi0ir=-8.0
Line 263 ⟶ 267:
-- use Irish definition of northing and easting
local e=100000.0*(ne.T1%5.0)+ne.e*ne.pr
local n=ne.n*ne.pr+100000.0*(4.0-math.floor(ne.T1/5.0))
local result = IrishEN2LL(e,n)
result.prec = 0.8165*ne.pr -- useful @ Commons
Line 385 ⟶ 389:
not mw.ustring.find(input,"type") and
not mw.ustring.find(input,"dim") and LL.prec then
url = url..'_dim:'..math.floor(50*LL.prec+0.5)..'m'
end
if not empty(namearg) then