Example #1
0
def choose_random_trip(date):
  sids = db.get_serviceIDs_for_date(date);

  randomsid = sids[ int( random()*len(sids) ) ]

  cur = db.get_cursor()
  db.SQLExec(cur, """
select trip_id from gtf_trips where service_id=%(sid)s order by random() limit 1
""",
             {'sid':randomsid})
  ret = cur.fetchall()
  cur.close()
  return ret[0][0]
Example #2
0
def choose_random_trip(date):
    sids = db.get_serviceIDs_for_date(date)

    randomsid = sids[int(random() * len(sids))]

    cur = db.get_cursor()
    db.SQLExec(
        cur, """
select trip_id from gtf_trips where service_id=%(sid)s order by random() limit 1
""", {'sid': randomsid})
    ret = cur.fetchall()
    cur.close()
    return ret[0][0]
Example #3
0
  sim = Simulation(gtfs_tracks.values()+gps_tracks,vizs);
  sim.run(speed=0,refresh_rate=0.1,windowsize=(1200,1200));

service_colors = {
  '1':pygame.Color(255,80,80),
  '2':pygame.Color(80,255,80),
  '3':pygame.Color(80,80,255)
}

if __name__ == "__main__":
  import dbqueries as db
  #test_tids = db.get_all_trip_ids_for_times('1','20000','21000');
  #test_tids = db.get_all_trip_ids_for_times('1','24000','30000');
  #test_GTFS(test_tids)
  #test_GPS('18',num=None);
  cur = db.get_cursor();
  cur.execute("""select gps_segment_id from gps_segments tr 
                   inner join gtf_trips gt on gt.trip_id=tr.trip_id 
                   inner join gtf_routes gr on gt.route_id = gr.route_id
                   inner join gtf_trip_information gti on gti.trip_id=gt.trip_id
                 where gr.route_short_name in ('5') --and
                 --where 27000 <= first_arrival and first_arrival <= 29000
              """
              );
  segids = [r['gps_segment_id'] for r in cur];
  cur.close();
  test_matched_GPS(segids);
  #test_matched_GPS(map(lambda i:str(i+1), range(500)))
  #test_matched_GPS(("35",))
  #test_matched_GPS(("1","2"))