TheTransitClock / transitime

TheTransitClock real-time transit information system
GNU General Public License v3.0
78 stars 29 forks source link

Change block_id of a trip at runtime #227

Closed zabuTNT closed 3 years ago

zabuTNT commented 3 years ago

Hi, I was wondering if TC contemplates the possibility to change the block_id assigned to one or more trips at runtime, only for the current day.

Let's assume we have this data in the trip.txt of GTFS provided:

route_id, trip_id, service_id, block_id
R1, T1, S1, B1
R1, T2, S1, B1
R1, T3, S2, B1
R2, T4, S3, B2

today, due a last minute problem, trip T2 cannot be carried out in block B1, but must be assigned to block B2.

The change is valid only for the current day and it is reasonable to think that the agency does not want to generate new GTFS, in addition to the fact that this reassignment could be made even just a few minutes before the departure of the vehicle (or start of shift).

I have seen in the code that a "supplement directory" for GTFS files is mentioned, but I cannot understand if and how it can be helpful to this case or not.

scrudden commented 3 years ago

Hi Federico,

Thanks for your interest in TheTransitClock.

I do not think this can be changed without restarting core.

You would need to re-import the GTFS file for the specific day, with a new trips.txt file in a specified supplementary directory with the block_id changes for the specific trip_id. This change to block_id is not something I have done before so I will be interested to hear how you get on.

Hope this helps.

Cheers,

Sean.

zabuTNT commented 3 years ago

Hi Sean, thank you, I looked more in the code about this supplementary directory in order to figure out how to do. I tried with a trips.txt with the new assignment blockId - tripId, and it seems sufficient for the use case.

2021-02-19-114514_670x445_scrot

Now I'm working on how automatize this procedure: supplementary trips.txt creation, reimport and restart of the core. I'm finding inspiration for a custom module looking here: https://github.com/TheTransitClock/transitime/blob/develop/transitclock/src/main/java/org/transitclock/custom/mbta/GenerateMbtaBlockInfo.java and maybe listen to events coming from others components (with RabbitMQ for instance?). I'll keep you informed. Best regards.

scrudden commented 3 years ago

Nice work! I think you may be on a good road. Keep us posted.

scrudden commented 3 years ago

Oh, just to mention there is a new proposed spec called "GTFS Service Changes" that may cover this use case. Might be worth a look.

https://docs.google.com/document/d/1oPfQ6Xvui0g3xiy1pNiyu5cWFLhvrTVyvYsMVKGyGWM/edit

zabuTNT commented 3 years ago

Thank you Sean, I'll read it for sure.

scrudden commented 3 years ago

Can this be closed? I think you have answered the original query.

If you are going to add a new feature it would be good to have it in a separate issue and hopefully with a matching pull request.

zabuTNT commented 3 years ago

Yes, this can be closed. Thank you.