def test_shape_break_order_1(self, trip_I=73775): """This is to a bug related to shape alignment.""" conn = GTFS('../scratch/db/hsl-2015-07-12.sqlite').conn cur = conn.cursor() cur.execute( '''SELECT seq, lat, lon FROM stop_times LEFT JOIN stops USING (stop_I) WHERE trip_I=? ORDER BY seq''', (trip_I, )) #print '%20s, %s'%(run_code, datetime.fromtimestamp(run_sch_starttime)) stop_points = [dict(seq=row[0], lat=row[1], lon=row[2]) for row in cur] # Get the shape points shape_id = cur.execute( '''SELECT shape_id FROM trips WHERE trip_I=?''', (trip_I, )).fetchone()[0] shape_points = shapes.get_shape_points(cur, shape_id) breakpoints, badness \ = shapes.find_segments(stop_points, shape_points) print(badness) if badness > 30: print("bad shape fit: %s (%s, %s)" % (badness, trip_I, shape_id)) for b1, b2 in zip(breakpoints, sorted(breakpoints)): self.assertEqual(b1, b2)
def _export_transfers(conn, fname): conn = GTFS(conn).conn cur = conn.cursor() cur.execute('SELECT S1.lat, S1.lon, S2.lat, S2.lon, SD.d ' 'FROM stop_distances SD ' ' LEFT JOIN stops S1 ON (SD.from_stop_I=S1.stop_I) ' ' LEFT JOIN stops S2 ON (SD.to_stop_I =S2.stop_I)') f = open(fname, 'w') for row in cur: print(' '.join(str(x) for x in row), file=f)