def main(cmd_name="bin/load_speed_data", via_bbox=True): # step 1: cmd line options to obtain session # import pdb; pdb.set_trace() session, args = make_session(cmd_name, return_args=True) # step 2: http get the latest traffic speed data from vendor (either via bbox or vendor's segment ids) if via_bbox: bbox = TrafficSegment.bbox(session, 0.001, normalize=True) speed_recs = speeds_via_bbox(bbox) else: segment_ids = TrafficSegment.get_segment_ids(session) ids = ','.join(map(str, segment_ids)) speed_recs = speeds_via_id(ids) if speed_recs and len(speed_recs) > 0: # step 3: test whether to clear the speed db table prior to loading new data if args.clear_speeds: TrafficSegmentSpeed.clear_tables(session) # step 4: persist that data to database Database.persist_data(session, speed_recs) # step 5: query the db and print out the speed data TrafficSegment.print_all(session, just_speeds=True) else: log.warning( "didn't see any speed data come back from the transit service ... " )
def main(cmd_name="bin/match_segments"): """ simple demo """ from ott.trafficdb.model.inrix.inrix_segment import InrixSegment session = make_session(cmd_name) segments = match_traffic_to_stop_segments(session, InrixSegment) if segments: TrafficSegment.clear_tables(session) Database.persist_data(segments)
def main(cmd_name="bin/bbox"): session = make_session(cmd_name) p = TrafficSegment.bbox(session) p = geo_utils.normalize_postgis_bbox(p) q = TrafficSegment.bbox(session, 0.001) q = geo_utils.normalize_postgis_bbox(q) print(p) print(q)
def main(): session, args = make_session("bin/publisher", return_args=True) do_print = False if args.output_dir else True publisher(session, args.output_dir, do_print)
def main(cmd_name="bin/view_map"): session, schema = make_session(cmd_name, return_schema=True) stop_geojson(session, schema) local_server()
def main(cmd_name="bin/printer", just_speeds=False): """ simple demo """ #import pdb; pdb.set_trace() session = make_session(cmd_name) TrafficSegment.print_all(session, just_speeds=just_speeds)