help doubt, GTFS Realtime Protobuf

113 views
Skip to first unread message

Rui M

unread,
Feb 6, 2020, 11:55:31 AM2/6/20
to GTFS-realtime
Following this how can I create a delay for the whole route, not just one trip.


***
syntax = "proto3";

package transit_realtime;

option java_package = "com.google.transit.realtime";

message FeedMessage {
    // Metadata about this feed and feed message.
    required FeedHeader header = 1;
 
    // Contents of the feed.
    repeated FeedEntity entity = 2;
 
  }
 
  message FeedHeader {

    required string gtfs_realtime_version = 1;

    enum Incrementality {
        FULL_DATASET = 0;
        DIFFERENTIAL = 1;
    }
    optional Incrementality incrementality = 2 [default = FULL_DATASET];

    optional uint64 timestamp = 3;


}

message FeedEntity {
    required string id = 1;

    optional bool is_deleted = 2 [default = false];

    optional TripUpdate trip_update = 3;
}

message TripUpdate {

    required TripDescriptor trip = 1;

    message StopTimeEvent {

        optional int32 delay = 1200;

        optional int32 uncertainty = 0;

    }

    repeated StopTimeUpdate stop_time_update = 2;

    optional uint64 timestamp = 4;

    optional int32 delay = 1200;

}

message TimeRange {
    optional uint64 start = 1;
 
    optional uint64 end = 2;
 
}

message TripDescriptor {
    optional string route_id = 9403;
 
    optional string start_time = 2;
    optional string start_date = 3;
 
    enum ScheduleRelationship {
      SCHEDULED = 0;
 
      ADDED = 1;
 
      UNSCHEDULED = 2;
 
      CANCELED = 3;
    }
    optional ScheduleRelationship schedule_relationship = 0;
 
  }

message EntitySelector {
    optional string agency_id = 1;
    optional string route_id = 9403;

}


***

Am I doing it correctly?

Sean Barbeau

unread,
Oct 9, 2020, 12:13:29 PM10/9/20
to GTFS-realtime
Rui,
First, you'll need to compile the gtfs-realtime.proto file into a library that can help you produce data in the binary protocol buffer format (the .proto file itself isn't the data that is exchanged between a producer and consumer). More here on this process:

Alternately, you can use the existing gtfs-realtime-bindings library, which has already done this step for you for several programming languages:

When you've done this, you'll need to write code to instantiate a TripUpdate with the TripDescriptor.route_id set to your route, and the TripUpdate.delay set to your delay value. Note that some consumers may not support this format - typically delays are created at the trip and stop level.

There are a number of GTFS-realtime demo apps here that might help you get started:

Sean
Reply all
Reply to author
Forward
0 new messages