Traewelling / traewelling

Free check-in service to log your public transit journeys
https://traewelling.de
GNU Affero General Public License v3.0
225 stars 43 forks source link

Negative trip times #37

Closed laugengebaeck closed 3 years ago

laugengebaeck commented 4 years ago

Describe the bug https://traewelling.de/status/129666 (which also seems to suffer from the bug described in https://github.com/Traewelling/traewelling/issues/10) and https://traewelling.de/status/129656 are trips with a negative journey time. The bus/train also seems to arrive at the destination before it leaves at the start.

To Reproduce Steps to reproduce the behavior:

  1. Search for Höhenstr., Potsdam
  2. Select an 603 bus to Platz der Einheit/West, Potsdam
  3. Check-in until Rathaus, Potsdam (any other stop might also work)
  4. Check the logged journey time as well as the arrival and departure times

Alternatively:

  1. Search for Berlin Westkreuz
  2. Select an S 42 train to Berlin Südkreuz (S)
  3. Check-in until Berlin-Tempelhof (any other stop after that might also work)
  4. Check the logged journey time as well as the arrival and departure times

Expected behavior The logged journey time should not be negative and the bus/train should not arrive before it has started. Also, the arrival time should be correct (the departure time is already correct).

Additional context The bug seems to happen when two busses (one-way and back) or two trains (two times around the circle) are squeezed into a single hafas trip. When this happens, stations can appear multiple times in one trip. It seems like Traewelling then internally chooses the first time a station appears in the trip as the destination, rather than that one the user really chose.

jeyemwey commented 4 years ago

The 603 Bus seams to be a ring structure, at least thats what the API gives me:

603 Ring Structure

I have modified the Check-In method, it will now match the stations with their arrival/departure times.

grafik

I will add some test cases (using the 603 bus) and then upload a PR.