Beispiel #1
0
    def test_reading(self):

        all_trips = TripLoader.get_all_trips("test/trips/0/")        
        for trip in all_trips[:10]:
            m = BusMatcher('test/shapes_up.txt')
            V=None
            p={}
            for location in trip.locations:                
                V,p = m.step((location.latitude,location.longitude),V,p)
            assert(m.current_shape(V)=="101")
Beispiel #2
0
import cv
from math import atan2,sqrt,ceil,pi
import sys,getopt,os
from location import TripLoader
from pylibs import spatialfunclib
from itertools import tee, izip

all_trips = TripLoader.get_all_trips("trips/")

##
## important parameters
##

cell_size = 2 # meters
mask_threshold = 100 # turns grayscale into binary
gaussian_blur = 17
voronoi_sampling_interval = 10 # sample one point every so many pixels along the outline
MIN_DIR_COUNT = 10
shave_until = 0.9999
trip_max = len(all_trips)

opts,args = getopt.getopt(sys.argv[1:],"c:t:b:s:hn:d:")
for o,a in opts:
    if o == "-c":
	cell_size=int(a)
    elif o == "-t":
	mask_threshold=int(a)
    elif o == "-b":
	gaussian_blur = int(a)	
    elif o == "-s":
	voronoi_sampling_interval = int(a)
    (opts, args) = getopt.getopt(sys.argv[1:], "p:v:d:b:r:n:h")

    for o, a in opts:
        if o == "-p":
            max_path_length = int(a)
        if o == "-v":
            min_graph_edge_volume = int(a)
        if o == "-d":
            location_projection_distance_limit = float(a)
        if o == "-b":
            location_bearing_difference_limit = math.cos(math.radians(
                float(a)))
        if o == "-r":
            trip_round = int(a)
        if o == "-n":
            trip_max = int(a)
        if o == "-h":
            print "Usage: python cao2009_generate_graph.py [-p <max_path_length>] [-v <min_graph_edge_volume>] [-d <location_projection_distance_limit>] [-b <location_bearing_difference_limit>] [-r <clarified_trips_round>] [-n <trip_max>] [-h]\n"
            exit()

    all_trips = TripLoader.get_all_trips("clarified_trips/n" + str(trip_max) +
                                         "/round" + str(trip_round) + "/")

    start_time = time.time()
    g = Graph(all_trips[:trip_max])
    g.generate_graph()

    print "\nGraph generation complete (in " + str(time.time() -
                                                   start_time) + " seconds).\n"
    # default values
    trip_round = 0
    trip_max = 889
    
    (opts, args) = getopt.getopt(sys.argv[1:],"p:v:d:b:r:n:h")
    
    for o,a in opts:
        if o == "-p":
            max_path_length = int(a)
        if o == "-v":
            min_graph_edge_volume = int(a)
        if o == "-d":
            location_projection_distance_limit = float(a)
        if o == "-b":
            location_bearing_difference_limit = math.cos(math.radians(float(a)))
        if o == "-r":
            trip_round = int(a)
        if o == "-n":
            trip_max = int(a)
        if o == "-h":
            print "Usage: python cao2009_generate_graph.py [-p <max_path_length>] [-v <min_graph_edge_volume>] [-d <location_projection_distance_limit>] [-b <location_bearing_difference_limit>] [-r <clarified_trips_round>] [-n <trip_max>] [-h]\n"
            exit()
    
    all_trips = TripLoader.get_all_trips("clarified_trips/n" + str(trip_max) + "/round" + str(trip_round) + "/")
    
    start_time = time.time()
    g = Graph(all_trips[:trip_max])
    g.generate_graph()
    
    print "\nGraph generation complete (in " + str(time.time() - start_time) + " seconds).\n"