Exemplo n.º 1
0
def distance_between(point, latitude, longitude):
    """
    Get the distance from this point to the specified coordinates in miles.
    """
    if latitude is None or longitude is None:
        return 0
    dist = distance()
    kilometers = dist.measure(point, Point(latitude, longitude))
    return miles(kilometers=kilometers)
Exemplo n.º 2
0
 def miles(self): # pylint: disable=C0111
     return units.miles(kilometers=self.kilometers)
Exemplo n.º 3
0
    """
    arcminutes = round(units.arcminutes(degrees=degrees - int(degrees)))
    arcseconds = units.arcseconds(arcminutes=arcminutes - int(arcminutes))
    format_dict = dict(
        symbols,
        degrees=degrees,
        minutes=abs(arcminutes),
        seconds=abs(arcseconds)
    )
    return fmt % format_dict

DISTANCE_FORMAT = "%(magnitude)s%(unit)s"
DISTANCE_UNITS = {
    'km': lambda d: d,
    'm': lambda d: units.meters(kilometers=d),
    'mi': lambda d: units.miles(kilometers=d),
    'ft': lambda d: units.feet(kilometers=d),
    'nm': lambda d: units.nautical(kilometers=d),
    'nmi': lambda d: units.nautical(kilometers=d)
}
def format_distance(kilometers, fmt=DISTANCE_FORMAT, unit='km'):
    """
    TODO docs.
    """
    magnitude = DISTANCE_UNITS[unit](kilometers)
    return fmt % {'magnitude': magnitude, 'unit': unit}

_DIRECTIONS = [
    ('north', 'N'),
    ('north by east', 'NbE'),
    ('north-northeast', 'NNE'),
Exemplo n.º 4
0
 def miles(self):
     return units.miles(kilometers=self.kilometers)
Exemplo n.º 5
0
 def miles(self):
     return units.miles(kilometers=self.kilometers)
Exemplo n.º 6
0
 def miles(self):  # pylint: disable=C0111
     return units.miles(kilometers=self.kilometers)