GTFS Static transit :: duplicate trip_id (trips.txt)

178 views
Skip to first unread message

Alexandre Martin

unread,
Jun 17, 2022, 6:36:40 AM6/17/22
to GTFS-realtime
Hello,


The description of the CSv trips.txt file leaves a doubt about the uniqueness of the trip_id field.
The trips.txt file makes the service_id, trip_id columns mandatory.
If a trip is reused by several services, is it allowed to generate the trips.txt file with duplicate trip_id?

The google documentation does not specify anything about this.

The validators block with a medium error.

Can you help me please?

Thank you.

Have a nice day,

Alexandre Martin

Translated with www.DeepL.com/Translator (free version)

Brody Flannigan

unread,
Jun 17, 2022, 8:58:24 AM6/17/22
to gtfs-r...@googlegroups.com
Hi Alexandre,

A trip_id must be unique, meaning there cannot be two rows in the CSV file with the same trip_id.

If the same trip operates on multiple services (For example, a northbound trip on route 1 at 8:30 AM runs on weekdays, saturdays and sundays), there are two ways to represent this:
1. Have multiple trips, one for each service, each with a unique trip_id
2. Have only one trip and create a calendar that specifically represents the operating days of this trip.
If you choose to go ahead with the second option and use the block_id field, be sure that the blocks are the same for the different service days.

Hope this helps!

--
You received this message because you are subscribed to the Google Groups "GTFS-realtime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gtfs-realtim...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gtfs-realtime/dbeb8dd2-194d-42b6-98a5-b5db72782419n%40googlegroups.com.

Alexandre Martin

unread,
Jun 17, 2022, 9:35:29 AM6/17/22
to GTFS-realtime
Thank you for your help and your quickly reply.

Unfortunately, the problem I am having is related to an AVL database.
The block_id field is already used by the driver duty information...
The AVL trips / journeys are factored and therefore duplicated in the theoretical GTFS export.

Strange that google does not mention in the documentation the rules of uniqueness of the fields.

I will try the first solution but I will lose client GTFS information.

Have a nice day,


Sincerely,

Alexandre Martin

Brody Flannigan

unread,
Jun 17, 2022, 11:43:52 AM6/17/22
to gtfs-r...@googlegroups.com
From my understanding, your CAD/AVL exports GTFS that is invalid because trips are duplicated (multiple trips with the same ID)
A solution could be to write a script that adds the service ID to the trip ID. For example, if a trip with ID TRIP1 operates on two services, SERVICE1 and SERVICE2, you could simply change the trip_ids to TRIP1_SERVICE1 and TRIP1_SERVICE2. Keep in mind though that if the CAD/AVL system is producing GTFS-RT, it will also need to be modified to add the service_id to the trip_id in GTFS-RT, in order for the RT to be valid.

Also, block_ids are not service-specific. There is an example of this in the reference document here. This might help you out a little bit.

If you have any questions don't hesitate to ask. (Je parle français aussi alors si vous souhaitez communiquer en français n'hésitez pas :))

ពិសិដ្ឋ កូនសម្លាញ់របស់ខ្ញុំ

unread,
Jun 17, 2022, 11:44:33 AM6/17/22
to gtfs-r...@googlegroups.com

នៅ​ថ្ងៃទី សុក្រ 17 មិថុនា 2022, 10:43 PM Brody Flannigan <Br...@flanny.ca> បាន​សរសេរ​ថា៖
Reply all
Reply to author
Forward
0 new messages