Module:Ordnance Survey coordinates/sandbox: Difference between revisions

Content deleted Content added
factor out geohack url generating code
fix bugs
Line 396:
 
-- generate URL of geohack map
local function geohack(inputmain_args, argsother_args, LL, restargs)
-- create geohack link. Example:
-- https://geohack.toolforge.org/geohack.php?pagename=Mount_Whitney&params=36.578580925_N_118.29199495_W_type:mountain_region:US-CA_scale:100000_source:NGS
local url = 'https://geohack.toolforge.org/geohack.php?'
local namearginput = argsmain_args["name"1]
local namearg = main_args["name"]
url = url..'https://geohack.toolforge.org/geohack.php?'
local current_page = mw.title.getCurrentTitle()
local pagename = mw.uri.encode( current_page.prefixedText, 'WIKI' )
Line 417:
url = url..mw.ustring.format('%.6f',LL.long)..'_E'
end
for i_, =a restargs,#argsin ipairs(other_args) do
url = url..'_'..args[i]a
end
if not mw.ustring.find(input,"region") and LL.region then
Line 434:
end
 
function oscoord._main(argsmain_args)
local input = argsmain_args[1]
if empty(input) then
return warning(nil)
end
local linktitle = argsmain_args[2]
local rawurl = yesno(argsmain_args["rawurl"])
local args = split(input,'_')
local LL
Line 472:
return linktitle ..warning(LL.err)
end
local other_args = {}
local url = geohack(input, args, LL, restargs)
for i = restargs, #args do
table.append(other_args, args[i])
end
local url = geohack(inputmain_args, argsother_args, LL, restargs)
if not rawurl then
url = '['..url..' '..linktitle..']'