Beispiel #1
0
def get_trip(url="file:./Winter%202012-2013.kml"):
    with urllib.request.urlopen(url) as source:
        path_iter = float_lat_lon(row_iter_kml(source))
        pair_iter = legs(path_iter)
        trip_iter = (Leg(start, end, round(haversine(start, end), 4))
                     for start, end in pair_iter)
        trip = tuple(trip_iter)
    return trip
Beispiel #2
0
def get_trip( url="file:./Winter%202012-2013.kml" ):
    with urllib.request.urlopen(url) as source:
        path_iter = float_lat_lon(row_iter_kml(source))
        pair_iter = legs(path_iter)
        trip_iter = (Leg(start, end, round(haversine(start, end),4))
            for start,end in pair_iter)
        trip= tuple(trip_iter)
    return trip
Beispiel #3
0
def get_trip_starmap(url):
    """
    >>> trip= get_trip_starmap( "file:./Winter%202012-2013.kml" )
    >>> len( trip )
    73
    >>> trip[0]
    Leg(start=Point(latitude=37.54901619777347, longitude=-76.33029518659048), end=Point(latitude=37.840832, longitude=-76.273834), distance=17.724564798884984)
    >>> trip[-1]
    Leg(start=Point(latitude=38.330166, longitude=-76.458504), end=Point(latitude=38.976334, longitude=-76.473503), distance=38.801864781785845)
    """
    with urllib.request.urlopen(url) as source:
        path_iter = float_lat_lon(row_iter_kml(source))
        pair_iter = legs(path_iter)
        make_leg = lambda start, end: Leg(start, end, haversine(start, end))
        trip = list(starmap(make_leg, pair_iter))
    return trip
Beispiel #4
0
def get_trip_starmap( url ):
    """
    >>> trip= get_trip_starmap( "file:./Winter%202012-2013.kml" )
    >>> len( trip )
    73
    >>> trip[0]
    Leg(start=Point(latitude=37.54901619777347, longitude=-76.33029518659048), end=Point(latitude=37.840832, longitude=-76.273834), distance=17.724564798884984)
    >>> trip[-1]
    Leg(start=Point(latitude=38.330166, longitude=-76.458504), end=Point(latitude=38.976334, longitude=-76.473503), distance=38.801864781785845)
    """
    with urllib.request.urlopen(url) as source:
        path_iter = float_lat_lon(row_iter_kml(source))
        pair_iter = legs(path_iter)
        make_leg = lambda start, end: Leg(start, end, haversine(start,end))
        trip = list( starmap( make_leg, pair_iter ) )
    return trip