Jump to content

Module:German coord convert

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Frietjes (talk | contribs) at 14:42, 4 September 2015. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}
function p.main(frame)
   local c = frame.args[1] or ''
   if mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[NEO][%s]*$') then
      local d, m, s = mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[NEO][%s]*$')
      return math.floor(1000000*(tonumber(d) + tonumber(m)/60 + tonumber(s)/3600) + 0.5)/1000000
   end
   if mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[SW][%s]*$') then
      local d, m, s = mw.ustring.match(c, '^[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9]*)[%s]*/[%s]*([0-9][0-9%.]*)[%s]*/[%s]*[SW][%s]*$')
      return -1*math.floor(1000000*(tonumber(d) + tonumber(m)/60 + tonumber(s)/3600) + 0.5)/1000000
   end
   return c
end
return p