syntax = "proto2";
option java_package = "com.google.transit.realtime";
package transit_realtime;
message FeedMessage {
  required FeedHeader header = 1;
  repeated FeedEntity entity = 2;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
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;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message FeedEntity {
  required string id = 1;
  optional bool is_deleted = 2 [default = false];
  optional TripUpdate trip_update = 3;
  optional VehiclePosition vehicle = 4;
  optional Alert alert = 5;
  optional Shape shape = 6;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message TripUpdate {
  required TripDescriptor trip = 1;
  optional VehicleDescriptor vehicle = 3;
  message StopTimeEvent {
    optional int32 delay = 1;
    optional int64 time = 2;
    optional int32 uncertainty = 3;
    extensions 1000 to 1999;
    extensions 9000 to 9999;
  }
  message StopTimeUpdate {
    optional uint32 stop_sequence = 1;
    optional string stop_id = 4;
    optional StopTimeEvent arrival = 2;
    optional StopTimeEvent departure = 3;
    optional VehiclePosition.OccupancyStatus departure_occupancy_status = 7;
    enum ScheduleRelationship {
      SCHEDULED = 0;
      SKIPPED = 1;
      NO_DATA = 2;
      UNSCHEDULED = 3;
    }
    optional ScheduleRelationship schedule_relationship = 5
        [default = SCHEDULED];
    message StopTimeProperties {
      optional string assigned_stop_id = 1;
      extensions 1000 to 1999;
      extensions 9000 to 9999;
    }
    optional StopTimeProperties stop_time_properties = 6;
    extensions 1000 to 1999;
    extensions 9000 to 9999;
  }
  repeated StopTimeUpdate stop_time_update = 2;
  optional uint64 timestamp = 4;
  optional int32 delay = 5;
  message TripProperties {
    optional string trip_id = 1;
    optional string start_date = 2;
    optional string start_time = 3;
    optional string shape_id = 4;
    extensions 1000 to 1999;
    extensions 9000 to 9999;
  }
  optional TripProperties trip_properties = 6;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message VehiclePosition {
  optional TripDescriptor trip = 1;
  optional VehicleDescriptor vehicle = 8;
  optional Position position = 2;
  optional uint32 current_stop_sequence = 3;
  optional string stop_id = 7;
  enum VehicleStopStatus {
    INCOMING_AT = 0;
    STOPPED_AT = 1;
    IN_TRANSIT_TO = 2;
  }
  optional VehicleStopStatus current_status = 4 [default = IN_TRANSIT_TO];
  optional uint64 timestamp = 5;
  enum CongestionLevel {
    UNKNOWN_CONGESTION_LEVEL = 0;
    RUNNING_SMOOTHLY = 1;
    STOP_AND_GO = 2;
    CONGESTION = 3;
    SEVERE_CONGESTION = 4;  // People leaving their cars.
  }
  optional CongestionLevel congestion_level = 6;
  enum OccupancyStatus {
    EMPTY = 0;
    MANY_SEATS_AVAILABLE = 1;
    FEW_SEATS_AVAILABLE = 2;
    STANDING_ROOM_ONLY = 3;
    CRUSHED_STANDING_ROOM_ONLY = 4;
    FULL = 5;
    NOT_ACCEPTING_PASSENGERS = 6;
    NO_DATA_AVAILABLE = 7;
    NOT_BOARDABLE = 8;
  }
  optional OccupancyStatus occupancy_status = 9;
  optional uint32 occupancy_percentage = 10;
  message CarriageDetails {
    optional string id = 1;
    optional string label = 2;
    optional OccupancyStatus occupancy_status = 3 [default = NO_DATA_AVAILABLE];
    optional int32 occupancy_percentage = 4 [default = -1];
    optional uint32 carriage_sequence = 5;
    extensions 1000 to 1999;
    extensions 9000 to 9999;
  }
  repeated CarriageDetails multi_carriage_details = 11;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message Alert {
  repeated TimeRange active_period = 1;
  repeated EntitySelector informed_entity = 5;
  enum Cause {
    UNKNOWN_CAUSE = 1;
    OTHER_CAUSE = 2;        // Not machine-representable.
    TECHNICAL_PROBLEM = 3;
    STRIKE = 4;             // Public transit agency employees stopped working.
    DEMONSTRATION = 5;      // People are blocking the streets.
    ACCIDENT = 6;
    HOLIDAY = 7;
    WEATHER = 8;
    MAINTENANCE = 9;
    CONSTRUCTION = 10;
    POLICE_ACTIVITY = 11;
    MEDICAL_EMERGENCY = 12;
  }
  optional Cause cause = 6 [default = UNKNOWN_CAUSE];
  enum Effect {
    NO_SERVICE = 1;
    REDUCED_SERVICE = 2;
    SIGNIFICANT_DELAYS = 3;
    DETOUR = 4;
    ADDITIONAL_SERVICE = 5;
    MODIFIED_SERVICE = 6;
    OTHER_EFFECT = 7;
    UNKNOWN_EFFECT = 8;
    STOP_MOVED = 9;
    NO_EFFECT = 10;
    ACCESSIBILITY_ISSUE = 11;
  }
  optional Effect effect = 7 [default = UNKNOWN_EFFECT];
  optional TranslatedString url = 8;
  optional TranslatedString header_text = 10;
  optional TranslatedString description_text = 11;
  optional TranslatedString tts_header_text = 12;
  optional TranslatedString tts_description_text = 13;
  enum SeverityLevel {
	UNKNOWN_SEVERITY = 1;
	INFO = 2;
	WARNING = 3;
	SEVERE = 4;
  }
  optional SeverityLevel severity_level = 14 [default = UNKNOWN_SEVERITY];
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message TimeRange {
  optional uint64 start = 1;
  optional uint64 end = 2;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message Position {
  required float latitude = 1;
  required float longitude = 2;
  optional float bearing = 3;
  optional double odometer = 4;
  optional float speed = 5;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message TripDescriptor {
  optional string trip_id = 1;
  optional string route_id = 5;
  optional uint32 direction_id = 6;
  optional string start_time = 2;
  optional string start_date = 3;
  enum ScheduleRelationship {
    SCHEDULED = 0;
    ADDED = 1;
    UNSCHEDULED = 2;
    CANCELED = 3;
    REPLACEMENT = 5 [deprecated=true];
    DUPLICATED = 6;
  }
  optional ScheduleRelationship schedule_relationship = 4;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message VehicleDescriptor {
  optional string id = 1;
  optional string label = 2;
  optional string license_plate = 3;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message EntitySelector {
  optional string agency_id = 1;
  optional string route_id = 2;
  optional int32 route_type = 3;
  optional TripDescriptor trip = 4;
  optional string stop_id = 5;
  optional uint32 direction_id = 6;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message TranslatedString {
  message Translation {
    required string text = 1;
    optional string language = 2;
    extensions 1000 to 1999;
    extensions 9000 to 9999;
  }
  repeated Translation translation = 1;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
message Shape {
  optional string shape_id = 1;
  optional string encoded_polyline = 2;
  extensions 1000 to 1999;
  extensions 9000 to 9999;
}
