code: def parse_altitude(cls, distance, unit):
          
          if distance is not None:
              distance = float(distance)
              CONVERTERS = {
                  'km': lambda d: d,
                  'm': lambda d: units.kilometers(meters=d),
                  'mi': lambda d: units.kilometers(miles=d),
                  'ft': lambda d: units.kilometers(feet=d),
                  'nm': lambda d: units.kilometers(nautical=d),
                  'nmi': lambda d: units.kilometers(nautical=d)
              }
              try:
                  return CONVERTERS[unit](distance)
              except KeyError:
                  raise NotImplementedError(
                      'Bad distance unit specified, valid are: %r' %
                      CONVERTERS.keys()
                  )
          else:
              return distance
docs: Parse altitude managing units conversion