Exemplo n.º 1
0
def zip_to_zip_miles(zip1, zip2):
    try:
        zip1 = ZIPS[zip1]
    except KeyError:
        raise ValueError(zip1)
    try:
        zip2 = ZIPS[zip2]
    except KeyError:
        raise ValueError(zip2)
    return distance_miles(Point(*zip1), Point(*zip2))
Exemplo n.º 2
0
def distance_to_zip_miles(point, zip):
    """Distance between a point and a zip

    Distance from Nashville International Airport (BNA) in Nashville to Los 
    Angeles International Airport (LAX) in Los Angeles:

        >>> lax = Point.from_degrees(33.94, -118.40)
        >>> int(distance_to_zip_miles(lax, "37217"))
        1794
        >>> bna = Point.from_degrees(36.12, -86.67)
        >>> distance_to_zip_miles(bna, "37217") # doctest: +ELLIPSIS
        1.29...
    """
    try:
        zip = ZIPS[zip]
    except KeyError:
        raise ValueError(zip)
    return distance_miles(point, Point(*zip))