Пример #1
0
 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)
         }
         return CONVERTERS[unit](distance)
     else:
         return distance
Пример #2
0
 def __init__(self, *args, **kwargs):
     kilometers = kwargs.pop('kilometers', 0)
     if len(args) == 1:
         # if we only get one argument we assume
         # it's a known distance instead of 
         # calculating it first
         kilometers += args[0]
     elif len(args) > 1:
         for a, b in util.pairwise(args):
             kilometers += self.measure(a, b)
    
     kilometers += units.kilometers(**kwargs)
     self.__kilometers = kilometers
Пример #3
0
    def __init__(self, *args, **kwargs):
        kilometers = kwargs.pop('kilometers', 0)
        if len(args) == 1:
            # if we only get one argument we assume
            # it's a known distance instead of
            # calculating it first
            kilometers += args[0]
        elif len(args) > 1:
            for a, b in util.pairwise(args):
                kilometers += self.measure(a, b)

        kilometers += units.kilometers(**kwargs)
        self.__kilometers = kilometers