1. Elliot Hallmark
  2. Where we meet


Where we meet / first_time.py

from WhereWeMeet import *
if __name__ == '__main__':

    #gen a map of travel times for source. 
    #area analyzed is defined by global variables at top of file
    #This is a demonstration of how to use the program.

    #run this once per area you are analyzing.  You can add to this data set whenever
    #generate grid of lats and longs for the working area

    #generate traveling times* (time intensive)

    #  *for one address only:
    source = 'bennu coffee, Austin Tx 78702'
    results = time_map_from_address(source, filename='data/001.csv')
    print 'time map results: %s, errors: %s' % tuple(results)    
    #  *for addresses defined in ./data/_address_list.csv
    #if user was already processed, they wont be processed again when this is run
    address_file = 'data/_address_list.csv'
    process_users(address_file, output_path ="data/")
    #calculate total driving time of all users to each point on grid
    #a different function could weight users differently in making this map
    #calculate contour data from csv file
    levels,colors,legend = get_contour_paths('data/_TKandL.csv',n=20)
    #set up map
    mymap = pygmaps.maps(center[0], center[1], 10)

    #display bounding box
    x1,y1 = ll
    x2,y2 = ur
    path = [(x1,y1), (x1,y2),(x2,y2),(x2,y1),(x1,y1)]
    mymap.addpath(path,color="#0000FF",fillcolor = "#000000", opacity=.2)

    #plot the acceptable area for final presentation
    acceptable_level = int(1)   #index to the contour level that is acceptable
    color = '#5555ee'
    print 'Highlighted area is under %s minutes.' % (legend[acceptable_level]/60.)
    for i,path in enumerate(levels[acceptable_level]):
            p =  map(tuple,path)   #contour includes full 

    #plot the other contour levels
    #select approriate lines to plot from 'levels' using slices
    for i,paths in enumerate(levels[::3][:3]):
        #colors slowly turns from blue to red, slice it differently to get faster change in color
        color='#%0.2x%0.2x%0.2x' % tuple([q*255 for q in colors[i*4][0][:-1]])
        for i,path in enumerate(paths):
            p =  map(tuple,path)    

    print "contour values: %s" % (legend,)