How to create a GTFS_RT feed from a bogus AVL feed in csv format

176 Views Asked by At

I am trying to produce a GTFS Realtime Feed from AVL data that a transit agency is providing. The thing is that there doesn't seem to be a link between the offical GTFS data and this AVL data set.

The vehicle position and 'lateness' data is under an url /gps_full.txt and is updated every 5-7 seconds. The format of the data is as follows:

TransportType,RouteShortName,TransitId,VehicleNumber,Longitude,Latitude,Speed,Azimuth,TripStartTime,DeviationInSeconds,MeasurementTime,VehicleType,
Bus,20,9790770943,7031,25206880,54644738,0,232,583,0,39179,KZ,
Trolleybus,6,9733751022,1681,25279878,54687890,0,18,622,93,39175,KZ,

The only primary key I could think of is a composite key (RouteShortName,TripStartTime) but I am not sure if that would not cause some collisions.

Is there any better way of doing this? Maybe someone had the same issue with data from other transit agencies and could point me to some resources?

I did try to search for resources myself but it seems that almost everyone had some sort of a link between the AVL feeds and static GTFS data.

All help will be greatly appreciated.

1

There are 1 best solutions below

1
On BEST ANSWER

If there really are no identifiers that allow you to link to the GTFS, the best you can do is guess which route/trip each vehicle is on.

TheTransitClock (an open-source version of Transitime that has continued to be updated and maintained) is a project that attempts to do this: https://github.com/TheTransitClock/transitime. I have never used it myself.

However, if you know the route and the trip start time, then you might be able to identify the scheduled trip (e.g., if the trip started at 09:00, go look in the GTFS schedule for trips on that route starting at 09:00). The logic for this could be quite complex (and essentially probabilistic) -- this is essentially a simplified version of what TheTransitClock is doing. I see that your data contains a TripStartTime field, although I don't understand the units.

Maybe the easiest approach would be to get in touch with the transit agency and ask if they could add the GTFS trip identifiers to the AVL data.