    def dmsToDd(self,dms):
        "patch to allow az in form: e.g. '-m N 25,34,40 E' - fl 9Nov2009"
        "minus sign allows handling bearings given in reverse direction"
        "'m' flags inputs as using magnetic or compass values"
        # this value needs to be obtained from input form
        magDev = 12.5 # for Maine, USA
        dms = dms.strip()
        if (dms[0] == '-'):
          rev = True
          dms = dms[1:].strip()
        else:
          rev = False
        if (dms[0] == 'm'):
          dev = magDev
          dms = dms[1:].strip()
        else:
          dev = 0.0
        baseDir = dms[0].upper()
        if (baseDir in ['N','S']):
          adjDir = dms[-1].upper()
          bearing = True
          if (baseDir == 'N'):
            if (adjDir == 'E'):
              base = 0.0
              adj = 'add'
            if adjDir == 'W':
              base = 360.0
              adj = 'sub'
          elif (baseDir == 'S'):
            base = 180.0
            if adjDir == 'E':
              adj = 'add'
            if adjDir == 'W':
              adj = 'sub'
        else:
          bearing = False
          
        "It's not fast, but it's a safe way of dealing with DMS"
        dms=dms.replace(" ", "")
        for c in dms:
            if not c.isdigit():
                dms=dms.replace(c,';')
        while (dms.find(";;")>=0):
            dms=dms.replace(";;",';')
        if dms[0]==';':
            dms=dms[1:]
        dms=dms.split(";")
        dd=0
        for i, f in enumerate(dms):
            if f!="":
                dd+=float(f)/pow(60, i)
        #dd=str(float(dms[0])+float(dms[1])/60+float(dms[2])/3600)
        
        "continuation of patch - fl 9Nov2009"
        if (rev):
          dd = dd+180
          if (dd > 360.0): dd = dd - 360.0
        if (bearing == True):
          if (adj == 'add'):
            dd = base + dd
          elif (adj == 'sub'):
            dd = base - dd
        dd = dd + dev
        
        return dd
    

