bliksemlabs / rrrr

RRRR rapid real-time routing
BSD 2-Clause "Simplified" License
164 stars 32 forks source link

Support for non time points, gtfs2rrrr error 'Negative times' #193

Open BennyKJohnson opened 9 years ago

BennyKJohnson commented 9 years ago

Hi, when parsing the Sydney Transport feed through gtfs2rrrr, an exception was raised "ValueError: Negative times". I worked out this error was due to the Sydney GTFS feed containing empty arrival and departure times for some of the stop times (None < 0 is true). According to the GTFS specifications it is valid to have empty arrival and departure times as long as they are not time points. https://developers.google.com/transit/gtfs/reference#stop_times_fields

I fixed this issue by storing the last valid arrival and departure times and substituting those values if arrival or departure time was null (none). This was a quick fix, though it would be beneficial to others if there was improvements made to the script to allow stop_times without times.

Trace:

    Traceback (most recent call last):
    File "gtfs2rrrr.py", line 109, in <module> main()
    File "gtfs2rrrr.py", line 102, in main
    tdata = convert(gtfsdb)
    File "gtfs2rrrr.py", line 80, in convert
    vj.add_stop(stop_id,arrival_time,departure_time,forboarding=(pickup_type != 1),foralighting=(drop_off_type != 1))
  File "model/transit.py", line 199, in add_stop
    raise ValueError('Negative times')
    ValueError: Negative times

Thanks

skinkie commented 9 years ago

We want to have a nice interpolated value here. Prererably taking the shape distance in account too.

koch-t commented 9 years ago

https://groups.google.com/forum/#!search/shape_dist_travelled/transit-developers/KH8Ug66A7fk/cpBelgYovUsJ I would give a -1 on using shape_dist_travelled for anything. Use as-the-crow-fly distances or if you really want it get the "real" distance via the shape itself