planarnetwork / dtd2mysql

MySQL / MariaDB import for DTD feeds (fares, timetable and routeing)
30 stars 10 forks source link

What is the use of addLateNightServices? #86

Closed miklcct closed 3 months ago

miklcct commented 6 months ago

Upon studying the code, addLateNightServices add a copy of the service to the previous day. Won't it produce duplicated service entries?

linusnorton commented 6 months ago

Yes, it does. Trains in the DTD system start their day at 4am, which is different to GTFS (and any sane person). I believe that code will look at trains after midnight the previous day and add them in the correct day. I believe they may end up being duplicated at 24:00+ departure trains (e.g. departing 25:30) which is completely valid in GTFS.

It's been many years since I looked at some of this so the details might be off but I believe that's it.

miklcct commented 6 months ago

The effect of the code is to add a copy of a train departing Monday 00:30 to depart at Sunday 24:30. I believe it may result in departure boards showing duplicate trains, however I haven't verified it yet in my deployment.

Btw are you the maintainer of gtfs.pro ?

linusnorton commented 6 months ago

No that's not me. I'm not actually involved with any rail stuff any more. Most of this stuff is just on life support.

miklcct commented 6 months ago

It does create duplicated journeys. Note that 00:52 appears twice for the London Overground.

Here is the output of our client now, which is connected to a server with a feed generated by a version without the call removed.

Screenshot_20240515-004549.png

linusnorton commented 6 months ago

I just re-read the code and it came back to me. Please ignore my first reply.

This was a hack I put in so that when you searched for journeys at the end of the day (e.g. 23:30) it would make connections with services after midnight without having to look for them on the next day.

I suggest we add a flag to disable this behaviour.

miklcct commented 3 months ago

After reviewing the GTFS spec, I think I need to restore the use of this function to produce DST-correct feeds.

The reason is because in the GTFS spec, the time of day is defined as starting from noon - 12 hours, which is different from midnight on days with DST changes.

https://github.com/google/transit/pull/15

The correct behaviour is to add a copy of a schedule departing before 02:00 into the previous service day, and remove it from the current service day, such that all services depart between 02:00 and 25:59 (with possible exception of Night Overground services which run on the repeated hour of autumn time change).

I will make a PR soon on this matter as it will affect trip matching when making GTFS-RT feeds.