def generate_tour_map(user_uuid): """ Generates tour map and saves it to result_template.html """ sys.path.append("%s/../../CFC_WebApp/" % os.getcwd()) import main.pygmaps_modified as pygmaps from main.gmap_display import drawSection from get_database import get_section_db, get_routeCluster_db gmap = pygmaps.maps(37.8717, -122.2728, 14) r = lambda: random.randint(0,255) canonical_trips = getUserTour(user_uuid) for section in canonical_trips: color = '#%02X%02X%02X' % (r(),r(),r()) print section._id section_json = get_section_db().find_one({'_id': section._id}) drawSection(section_json, 'path', gmap, color) try: os.remove('clients/commontrips/result_template.html') except OSError, e: print "Result of removing the result template is %s" % e
def generate_tour_map(user_uuid): """ Generates tour map and saves it to result_template.html """ sys.path.append("%s/../../CFC_WebApp/" % os.getcwd()) import main.pygmaps_modified as pygmaps from main.gmap_display import drawSection from get_database import get_section_db, get_routeCluster_db gmap = pygmaps.maps(37.8717, -122.2728, 14) r = lambda: random.randint(0, 255) canonical_trips = getUserTour(user_uuid) for section in canonical_trips: color = '#%02X%02X%02X' % (r(), r(), r()) print section._id section_json = get_section_db().find_one({'_id': section._id}) drawSection(section_json, 'path', gmap, color) try: os.remove('clients/commontrips/result_template.html') except OSError, e: print "Result of removing the result template is %s" % e
print("USAGE: %s trip_id\n" % sys.argv[0]) print("option: -o , immediately open file in default browser") print("OUTPUT: plot will be stored at ./plots/trip_id.html") print("COLOR SCHEME FOR THE PLOT:\n") print("walking - blue\nrunning - green\ncycling - yellow\ntransport - red\nbus - aqua\ntrain - darkOrange\ncar - grey\nmixed - olive\nair -skyBlue\n") exit(1) else: trip_id = sys.argv[1] sections =db.Stage_Sections.find({'trip_id': trip_id}) if sections.count() == 0: print("\nTRIP NOT FOUND\n") exit(1) startpoint = sections[0]['section_start_point'] distance = sections[0]['distance'] gmap = None startCoord = None if startpoint == None: print("start_point missing corodinates") else: startCoord = startpoint['coordinates'] gmap = pygmaps.maps(startCoord[1], startCoord[0], min(15, old_div(165000.0,distance))) gmap_display.drawTrip(trip_id, db, gmap) if not os.path.exists('plots'): os.makedirs('plots') gmap.draw('plots/' + trip_id + '.html') try: if sys.argv[2] == '-o': webbrowser.open('plots/' + trip_id + '.html') except: exit(1)
print "USAGE: %s trip_id\n" % sys.argv[0] print "option: -o , immediately open file in default browser" print "OUTPUT: plot will be stored at ./plots/trip_id.html" print "COLOR SCHEME FOR THE PLOT:\n" print "walking - blue\nrunning - green\ncycling - yellow\ntransport - red\nbus - aqua\ntrain - darkOrange\ncar - grey\nmixed - olive\nair -skyBlue\n" exit(1) else: trip_id = sys.argv[1] sections =db.Stage_Sections.find({'trip_id': trip_id}) if sections.count() == 0: print "\nTRIP NOT FOUND\n" exit(1) startpoint = sections[0]['section_start_point'] distance = sections[0]['distance'] gmap = None startCoord = None if startpoint == None: print "start_point missing corodinates" else: startCoord = startpoint['coordinates'] gmap = pygmaps.maps(startCoord[1], startCoord[0], min(15, 165000.0/distance)) gmap_display.drawTrip(trip_id, db, gmap) if not os.path.exists('plots'): os.makedirs('plots') gmap.draw('plots/' + trip_id + '.html') try: if sys.argv[2] == '-o': webbrowser.open('plots/' + trip_id + '.html') except: exit(1)
print "option: -o , immediately open file in default browser" print "OUTPUT: plot will be stored at ./plots/trip_id.html" print "COLOR SCHEME FOR THE PLOT:\n" print "walking - blue\nrunning - green\ncycling - yellow\ntransport - red\nbus - aqua\ntrain - darkOrange\ncar - grey\nmixed - olive\nair -skyBlue\n" exit(1) else: trip_id = sys.argv[1] sections = db.Stage_Sections.find({'trip_id': trip_id}) if sections.count() == 0: print "\nTRIP NOT FOUND\n" exit(1) startpoint = sections[0]['section_start_point'] distance = sections[0]['distance'] gmap = None startCoord = None if startpoint == None: print "start_point missing corodinates" else: startCoord = startpoint['coordinates'] gmap = pygmaps.maps(startCoord[1], startCoord[0], min(15, 165000.0 / distance)) gmap_display.drawTrip(trip_id, db, gmap) if not os.path.exists('plots'): os.makedirs('plots') gmap.draw('plots/' + trip_id + '.html') try: if sys.argv[2] == '-o': webbrowser.open('plots/' + trip_id + '.html') except: exit(1)
print("COLOR SCHEME FOR THE PLOT:\n") print( "walking - blue\nrunning - green\ncycling - yellow\ntransport - red\nbus - aqua\ntrain - darkOrange\ncar - grey\nmixed - olive\nair -skyBlue\n" ) exit(1) else: trip_id = sys.argv[1] sections = db.Stage_Sections.find({'trip_id': trip_id}) if sections.count() == 0: print("\nTRIP NOT FOUND\n") exit(1) startpoint = sections[0]['section_start_point'] distance = sections[0]['distance'] gmap = None startCoord = None if startpoint == None: print("start_point missing corodinates") else: startCoord = startpoint['coordinates'] gmap = pygmaps.maps(startCoord[1], startCoord[0], min(15, old_div(165000.0, distance))) gmap_display.drawTrip(trip_id, db, gmap) if not os.path.exists('plots'): os.makedirs('plots') gmap.draw('plots/' + trip_id + '.html') try: if sys.argv[2] == '-o': webbrowser.open('plots/' + trip_id + '.html') except: exit(1)