--

           local p = {} 
           local LuaWiki = require( "Module:LuaWiki" )

         --[=[
           function LatRange(fNumber)
              if not tonumber(fNumber) then
                 ErrMsg(ErrCode='NAN', ErrFun='LatRange',ErrData= "input=".. tostring(fNumber))
                 return nil
              end
              if fNumber >  90 then return  90; end
              if fNumber < -90 then return -90; end
              return fNumber;
           end

           function WGS84toCH1903(label,lat,lon,prec)
              local b_lbl = (label or "" ) ~= "";
              local n     =  floor (tonumber(prec) or 0);
              if( lat < 45.7 or lat > 47.9 or lon < 5.8 or lon > 10.6 ) then
                 ErrMsg(ErrCode='OOR', ErrFun='WGS84toCH1903',ErrData="keine")
              end
              -- genaue Berechnung, Lua kann sich das leisten
              local phi    = (lat * 3600 - 169028.66 ) /10000;
              local lambda = (lon * 3600 - 26782.5) / 10000;
              local x = 200147.07 + 308807.95 * phi    +  3745.25 * lambda^2 +    76.63 * phi^2 + 119.79 * phi^3 - 194.56 * lambda^2 * phi;
              local y = 600072.37 + 211455.93 * lambda - 10938.51 * lambda * phi - 0.36 * lambda * phi^2 - 44.54 * lambda^3;
              x = (floor(x* 10^n + 0.5))/10^n;
              y = (floor(y* 10^n + 0.5))/10^n;
              return x,y;
           end

         ]=]

            local function ErrMsg(ErrCode, ErrFun, ErrData)
               local ErrText = ""
               local T_Error ={
                  ['NAN']   = "Keine Zahl",                           -- not a number
                  ['OOR']   = "Wert nicht im gültigen Bereich",       -- out of range
                  ['BSTR']  = "Ungültiger Parameterstring",             -- bad text
                  ['BPAR']  = "Ungültiger Parametername",             -- bad parameter
                  ['DIVZ']  = "Division durch Null!"                  -- Muss abgefangen werden
                  }
               -- ErrCode = nil ? Dann "Fehler in Fehlermeldung"
               if not ErrCode then
                  return nil
               end

               ErrText = "<span class='error'>Funktion " .. ErrFun .. ": " ..T_Error[ErrCode]
               if ErrData then
                  ErrText = ErrText .. " Daten: <code>".. ErrData .."</code>"
                  end
               ErrText = ErrText .."</span>"
               return ErrText
            end


            local function DMS2dez(Grad,Min,Sek)    -- voellig, egal, wenn einer 61 Min eingibt!
               Grad = tonumber(Grad)
               Min  = tonumber(Min)
               Sek  = tonumber(Sek)
               if not Grad or not Min or not Sek then
                  return 0,false
               end
               return  Grad + Min /60 + Sek /3600 , true
            end

            local function LatDMS(tbl)
               local data = 0;
               if not (tbl[4]=="N" or tbl[4]=="S") then
                  data = tostring(tbl[4])
                  ErrMsg("BSTR","LatDMS", data)
                  return 0, false
               end
               data = DMS2dez(tbl[1],tbl[2],tbl[3])
               if not data then
                  ErrMsg('NAN','LatDMS',table.concat(tbl," ! "))
                  return 0, false
               end
               if tbl[4]=="S" then data = 0 - data; end
               if data < -90 or data >90 then
                  ErrMsg('OOR', 'LatDMS',data)
                  return 0, false
               end
               return data,true
            end

            local function LonDMS(tbl)
               local data = 0
               if not (tbl[4]=="O" or tbl[4]=="E" or tbl[4]=="O" )then
                  data = tostring(tbl[4])
                  ErrMsg('BPAR', 'LonDMS',data)
                  return 0, false
               end
               data = DMS2dez(tbl[1],tbl[2],tbl[3])
               if not data then
                  ErrMsg('NAN','LonDMS', table.concat(tbl," ! "))
                  return  0, false
               end
               if tbl[4]=="W" then data = 0 - data; end
               if data < -180 or data >180 then
                  ErrMsg('OOR','LonDMS',"data=" .. tostring(data))
                  return  0, false
               end
               return data, true
            end


            -- function wb: kurz fuer "wikibool". Emulation der Wikilogik: Gibt true zurueck, wenn para nicht leer ist.
            local function wb(para)
               return (para or "") ~= "";
            end

            -- function splitbyslash: Emulation von titleparts. Rückgabe per table.
            local function splitbyslash(para)
               local tbl = {};
               local rest= para;
               local teil=""
               local pos
               for idx= 1,4 do
                  pos = string.find(rest,'/',1,true);
                  if not pos then
                     table.insert(tbl,rest)
                     if idx == 2 then
                        table.insert(tbl,2,'0')
                        table.insert(tbl,2,'0')
                     end
                     if idx == 3 then
                        table.insert(tbl,3,'0')
                     end
                     break
                  end
                  if pos == 1 then
                     table.insert(tbl,"")
                     rest = string.sub(rest,2,-1)
                  else
                     teil = string.sub(rest,    1,pos-1)
                     rest = string.sub(rest,pos+1,   -1)
                     table.insert(tbl,teil)
                  end
               end
               if tonumber(tbl[1]) and tonumber(tbl[2]) and tonumber(tbl[3]) and not tonumber(tbl[4]) then
                  return tbl, true
               end
               return  tbl, false
            end

            function p.Execute(frame)
               local lat = 0
               local lon = 0
               local T_Para = {}  -- nimmt die Parameter auf
               local T_bPara = {} -- logischer Wert nach Wikilogik
               local T_temp = {}
               -- Einzelzuweisung fuer benannte Indices und damit auch ganz fehlende Parameter (nil) als Leerstring eingefuegt werden.
               T_Para['NS']            = frame.args['NS']            or "";
               T_Para['EW']            = frame.args['EW']            or "";
               T_Para['type']          = frame.args['type']          or "";
               T_Para['region']        = frame.args['region']        or "";
               T_Para['globe']         = frame.args['globe']         or "";
               T_Para['dim']           = frame.args['dim']           or "";
               T_Para['elevation']     = frame.args['elevation']     or "";
               T_Para['pop']           = frame.args['pop']           or "";
               T_Para['name']          = frame.args['name']          or "";
               T_Para['simple']        = frame.args['simple']        or "";
               T_Para['article']       = frame.args['article']       or "";
               T_Para['text']          = frame.args['text']          or "";
               T_Para['sortkey']       = frame.args['sortkey']       or "";
               T_Para['tooltip']       = frame.args['tooltip']       or "";
               T_Para['tooltipformat'] = frame.args['tooltipformat'] or "";
               T_Para['map']           = frame.args['map']           or "";
               T_Para['mapsize']       = frame.args['mapsize']       or "";
               T_Para['maplevel']      = frame.args['maplevel']      or "";
               T_Para['maptype']       = frame.args['maptype']       or "";
               T_Para['maplabel']      = frame.args['maplabel']      or "";
               T_Para['maplayer']      = frame.args['maplayer']      or "";
               for sidx, str in pairs(T_Para) do
                  T_bPara[sidx] = wb(T_Para[sidx]) -- str nicht genutzt
               end
               if not T_bPara['NS'] or not T_bPara['EW'] then
                  ErrMsg('BPAR','Execute','no NS or no EW')   -- NS und EW sind zwingend noetig
                  return "",false
               end
               if not tonumber(T_Para['NS']) then
                  T_temp = splitbyslash(T_Para['NS'])
                  if #T_temp < 4 then
                     ErrMsg('BTXT','Execute','zu wenig Teile im Slashstring NS')
                     return "",false
                  end
                  lat = LatDMS(T_temp)
               else
                  lat = tonumber(T_Para['NS'])
               end
               if not tonumber(T_Para['EW']) then
                  T_temp = splitbyslash(T_Para['EW'])
                  if #T_temp < 4 then
                     ErrMsg('BSTR','Execute','zu wenig Teile im Slashstring EW')
                     return "",false
                  end
                  lon = LonDMS(T_temp)
               else
                  lon = tonumber(T_Para['EW'])
               end
               -- Rest fehlt noch
               return tostring(lat) .. "\n" .. tostring(lon)
           end

           return p
        --