Exemplo n.º 1
0
def main():
        #Load all files and initilize Simple Tracks
    os.chdir("/home/moyano/Projects/CreateTracks/trips/")
    all_points = []
    for trip in os.listdir("."):
            trip_data = load_file(trip)
            all_points += trip_data
            #tracks.append(Track(trip_data))
            
    boundries = max_bounding_rect(all_points)
   # depth = depth(boundries, 0.00035)
    #print "Nesting Level: %i" % depth
    qtree = QuadTree(10, boundries)
    #Make the QTree
    for coord in all_points:
        qtree.add_point(coord)
    qtree.traverse()
    nodes = qtree.leaves

    #Load Trips
    trips = []
    for trip in os.listdir("."):
        if not trip.startswith('.'):

            gps_data = load_file(trip)
            trips.append(Trip(gps_data,trip))

    routes(trips, qtree)

    #Weighted Points
    os.chdir("/home/moyano/Projects/CreateTracks/edges")
    test_file = open("edges.txt", "w")
    test_file.write("latitude, longitude, ocurrences, color")
    # print children
    for node in nodes:
        p = node._center_of_mass()
        count = len(node.items)
        if count > 2:
            test_file.write("\n")  
            test_file.write(str(p.latitude) + "," + str(p.longitude) + "," + str(count) + "," + get_color(count))

    #All points
    os.chdir("/home/moyano/Projects/CreateTracks/edges")
    test_file = open("edges2.csv", "w")
    test_file.write("latitude, longitude")
    test_file.write("#")  
    # print children
    xpoints = []
    for node in nodes:
        p = node._center_of_mass()
        count = len(node.items)
        if count > 100:

            for _ in xrange(count):
                xpoints.append((p.latitude, p.longitude))
                test_file.write(str(p.latitude) + ", " + str(p.longitude))
                test_file.write("#")