Content deleted Content added
drop unused |
factor out data |
||
(11 intermediate revisions by the same user not shown) | |||
Line 71:
-- Datum parameters
local data = mw.loadData('Module:Ordnance Survey coordinates/data')
local
local IEglobe = data.IEglobe
local WGSglobe = data.WGSglobe
local WGS2OSGBparam = data.WGS2OSGBparam
local OSGB2WGSparam = data.OSGB2WGSparam
local IE2WGSparam = data.IE2WGSparam
local function HelmertDatumShift ( latitude , longitude, param )
Line 407 ⟶ 337:
url = url..'pagename='..pagename..'&'
end
url = url..'params='..mw.ustring.format('%.6f',LL.lat)..'_N_'
if LL.long < 0 then
Line 431 ⟶ 357:
url = url .. "&title=" .. mw.uri.encode(namearg)
end
return url
end
-- function to generate direct link to OS map
local function directLink(main_args, other_args, LL)
-- create link to Bing server for OS maps. Example:
-- https://www.bing.com/maps/?mkt=en-gb&v=2&cp=56.796026%7E-5.01307&lvl=16.0&sp=Point.56.796029_-5.004711_Ben+Nevis&sty=s&style=s
local current_page = mw.title.getCurrentTitle()
local namearg = mw.uri.encode( main_args["name"] or current_page.prefixedText, 'QUERY' )
local args = {}
for _, a in ipairs(other_args) do
local splitOut = mw.text.split(a, ':', true)
args[splitOut[1]] = splitOut[2]
end
if not args.scale and not args.type and not args.dim then
args.dim = LL.prec and tostring(floor(50*LL.prec+0.5))..'m'
end
args.viewport_cm = 10
local zoom = require('Module:Infobox dim')._zoom
local lvl = zoom(args) or 12
local url = mw.ustring.format('https://www.bing.com/maps/?mkt=en-gb&v=2&cp=%.6f~%.6f&lvl=%d&sp=Point.%.6f_%.6f',LL.lat,LL.long,lvl,LL.lat,LL.long)
if not empty(namearg) then
url = url..'_'..namearg
end
url = url..'&sty=s&style=s'
return url
end
Line 441 ⟶ 392:
local linktitle = main_args[2]
local rawurl = yesno(main_args["rawurl"])
local direct = yesno(main_args["direct"])
local args = split(input,'_')
local LL
Line 472 ⟶ 424:
return linktitle ..warning(LL.err)
end
LL.lat = LL.lat or 0
LL.long = LL.long or 0
LL.lat = ceil(LL.lat*1000000)/1000000
LL.long = ceil(LL.long*1000000)/1000000
local other_args = {}
for i = restargs, #args do
table.insert(other_args, args[i])
end
local url
if not direct then
url = geohack(main_args, other_args, LL)
else
url = directLink(main_args, other_args, LL)
end
if not rawurl then
url = '['..url..' '..linktitle..']'
|