brnstz / bus

Mobile web app for discovering public transit in NYC --
https://token.live
MIT License
5 stars 2 forks source link

Mismatch between realtime MTA subway trip_id and DB trip_ids #63

Closed brnstz closed 8 years ago

brnstz commented 8 years ago
2016/07/05 10:42:24 trip.go:142: can't get trip
        SELECT *
        FROM trip
        WHERE agency_id = $1 AND
              trip_id = $2 AND
              route_id = $3
     MTA NYCT 061600_L..N L sql: no rows in result set
2016/07/05 10:42:24 api_here.go:293: can't get trip MTA NYCT|061600_L..N sql: no rows in result set
bseitz=# select trip_id from trip where route_id = 'L' and trip_id like '%61600%';
           trip_id
-----------------------------
 B20160612WKD_061600_L..S01R
 B20160612WKD_061600_L..N01R
(2 rows)
brnstz commented 8 years ago

From http://datamine.mta.info/sites/all/files/pdfs/GTFS-Realtime-NYC-Subway%20version%201%20dated%207%20Sep.pdf

Unfortunately, there is no reliable way for us to determine the relationship between the actual and the static GTFS trip, so we can’t tell if a particular trip is the original one or has been changed or added later so the ScheduleRelationship is not used. While trip_id in the GTFS-realtime feed will not directly match the trip_id in trips.txt, a partial match should be possible if the trip has been defined in trips.txt. If there is a partial match, the trip is a scheduled trip. For example, if a trip_id in trips.txt is A20111204SAT_021150_2..N08R, the GTFS-realtime trip_id will be 021150_2..N08R which is unique within the day type (WKD, SAT, SUN).

brnstz commented 8 years ago

https://github.com/brnstz/bus/commit/427a9be99956b952f98f9c2c9b6f2ca5b5c9573d