[GTFS-RT] Trip cancellation in Alerts & Trip Update

Hi,

I am trying to scrape the cancellation information from both the Alerts and Trip Update APIs.

I have noted the following:

  1. Would all cancellations be transmitted via the Alerts API?
  2. Within Trip Update, the documentation suggests the trip and stop schedule_relationship fields should be contain text entries. However, I could only see binary results (0 and 1). In addition, it seems the binary trip schedule_relationship is not working properly, e.g. there should be two cancellations on 19 January 2018 from the @FerriesInfo Twitter feeds, but the GTFS-RT feed only shows 0.
  3. If neither Alerts API nor Trip Update API works, what is my alternative(s) to get cancellation information?

Thank you.

Hi James,

  1. For trains, cancellations are usually communicated using both as text via the Service Alerts feed and via the Trip Updates feed (schedule_relationship: CANCELED). The source system for these two data feeds are different, so some trips may appear as cancelled in one feed before it appears in the other one.

    I’d suggest using both feeds if you want a more comprehensive list of cancelled services. Some cancellations may get left out of one of the feeds – especially during major disruptions or in early hours of the morning.

    For buses, this is only communicated using the Trip Updates feed.

  2. The Trip Updates are based on the GTFS-realtime specification. schedule_relationship should be an enum and is communicated via Protocol Buffers as the index of the enum. Depending on the particular parsing library you’re using, it may or may not transform this into the string form… you’ll need to check that with the developer of the library you’re using.

Hope that answers your question.

Cheers,
Ken

Hi Ken,

Much appreciate the quick response. I am uncertain if the response answers my question. Maybe I did not make myself clear. I was talking specifically about ferries.

To elaborate further corresponding to your responses:

  1. We are now collecting both Service Alerts and Trip Updates. However, if the only difference between these two feeds is timing, then I am not seeing that - I do not see any Cockatoo Island trip cancelled in the Trip Updates on 19 January 2018, although the FerriesInfo Twitter account suggests otherwise;
  2. By schedule_relationship enum, do you mean the Trip Descriptor on 行程更新  |  即時大眾運輸資訊  |  Google Developers? If so, I might be the unfortunate one, as I only see 0s (not even 1s) - again for Cockatoo Island on 19 January 2018.

Could you please help me address these issues?

Thank you.
James

Ah, ferries. The ferries TripUpdates feed does use the CANCELED schedule relationship. For example, RV115-4116 was cancelled this morning:

entity {
  id: "1150f59f-84c4-4a69-8bbc-ecb6ed33ccfc"
  trip_update {
    trip {
      trip_id: "RV115-4116"
      schedule_relationship: CANCELED
      route_id: "RV"
    }
    vehicle {
      id: "1023"
      label: "Anne Sargeant"
    }
    timestamp: 1518740224
  }
}

As per trains, it might not be all-encompassing because they are manually entered and are in two separate systems. iirc, the ferry GTFS-R Alerts API doesn’t have trip cancellations… so you might also want to parse the Trip Planner add_info endpoint for those types of service alerts.

You’ll need to do some transformation to match route IDs and trips from start times.

Yep, the TripDescriptor’s ScheduleRelationship. If you’re only seeing 0s, that would mean all the trip entities are returning a SCHEDULED value. 1 would indicate ADDED, 2 for UNSCHEDULED… etc.

Check the .proto file for more info:

  enum ScheduleRelationship {
    // Trip that is running in accordance with its GTFS schedule, or is close
    // enough to the scheduled trip to be associated with it.
    SCHEDULED = 0;

    // An extra trip that was added in addition to a running schedule, for
    // example, to replace a broken vehicle or to respond to sudden passenger
    // load.
    ADDED = 1;

    // A trip that is running with no schedule associated to it, for example, if
    // there is no schedule at all.
    UNSCHEDULED = 2;

    // A trip that existed in the schedule but was removed.
    CANCELED = 3;
  }

Thanks Ken,

This solves the problem. We were using a different gtfs-realtime.proto file.

Thank you for your help.

James

1 Like