syntax = "proto3";

package minotor.timetable;

message Route {
  /**
   * Arrivals and departures encoded as a 32 bit uint array.
   * Format: [arrival1, departure1, arrival2, departure2, etc.]
   */
  bytes stopTimes = 1;
  /**
   * PickUp and DropOff types represented as an 8 bit uint array.
   * Values:
   *   0: REGULAR
   *   1: NOT_AVAILABLE
   *   2: MUST_PHONE_AGENCY
   *   3: MUST_COORDINATE_WITH_DRIVER
   * Format: [pickupTypeStop1, dropOffTypeStop1, pickupTypeStop2, dropOffTypeStop2, etc.]
   */
  bytes pickUpDropOffTypes = 2;
  /**
   * Stops encoded as a 32 bit uint array.
   * Format: [stop1, stop2, stop3, etc.]
   */
  bytes stops = 3;
  string serviceRouteId = 4;
}

message RoutesAdjacency {
  map<string, Route> routes = 1;
}

enum TransferType {
  RECOMMENDED_TRANSFER_POINT = 0;
  TIMED_TRANSFER = 1;
  REQUIRES_MINIMAL_TIME = 2;
  IN_SEAT_TRANSFER = 3;
}

message Transfer {
  uint32 destination = 1;
  TransferType type = 2;
  optional int32 minTransferTime = 3;
}

message StopsAdjacency {
  message StopAdjacency {
    repeated Transfer transfers = 1;
    repeated string routes = 2;
  }
  map<string, StopAdjacency> stops = 1;
}

enum RouteType {
  TRAM = 0;
  SUBWAY = 1;
  RAIL = 2;
  BUS = 3;
  FERRY = 4;
  CABLE_TRAM = 5;
  AERIAL_LIFT = 6;
  FUNICULAR = 7;
  TROLLEYBUS = 8;
  MONORAIL = 9;
}

message ServiceRoute {
  RouteType type = 1;
  string name = 2;
}

message ServiceRoutesMap {
  map<string, ServiceRoute> routes = 1;
}

message Timetable {
  string version = 1;
  StopsAdjacency stopsAdjacency = 2;
  RoutesAdjacency routesAdjacency = 3;
  ServiceRoutesMap routes = 4;
}
