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:40, 4 September 2015 (for converting coordinates from the German WP). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
local p = {}
function p.main(frame)
   local c = 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.round(1000000*(tonumber(d) + tonumber(m)/60 + tonumber(s)/3600))/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.round(1000000*(tonumber(d) + tonumber(m)/60 + tonumber(s)/3600))/1000000
   end
   return c
end