// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package maps.fleetengine.v1;

import "google/api/field_behavior.proto";
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "google/type/latlng.proto";

option go_package = "google.golang.org/genproto/googleapis/maps/fleetengine/v1;fleetengine";
option java_multiple_files = true;
option java_outer_classname = "FleetEngine";
option java_package = "google.maps.fleetengine.v1";
option objc_class_prefix = "CFE";

// Identifies a terminal point.
message TerminalPointId {
  // Deprecated.
  oneof Id {
    // Deprecated.
    string place_id = 2 [deprecated = true];

    // Deprecated.
    string generated_id = 3 [deprecated = true];
  }

  // Unique ID of the terminal point.
  string value = 4;
}

// Describes the location of a pickup or dropoff.
message TerminalLocation {
  // Required. Denotes the actual location of a pickup or dropoff.
  google.type.LatLng point = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. ID of the terminal point.
  TerminalPointId terminal_point_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Deprecated.
  string access_point_id = 3 [deprecated = true];

  // Deprecated. Use vehicle.waypoint instead.
  string trip_id = 4 [deprecated = true];

  // Deprecated. Vehicle.waypoint will have this data.
  WaypointType terminal_location_type = 5 [deprecated = true];
}

// Describes a stopping point on a vehicle's route or an ending point on a
// vehicle's trip.
message TripWaypoint {
  // The location where this waypoint is
  TerminalLocation location = 1;

  // The trip this waypoint is part of
  string trip_id = 2;

  // The type described the role the waypoint plays for this trip such as a
  // pickup or dropoff.
  WaypointType waypoint_type = 3;

  // The path calculated by Fleet Engine from the previous waypoint to the
  // current waypoint.
  repeated google.type.LatLng path_to_waypoint = 4;

  // The path distance calculated by Fleet Engine from the previous waypoint to
  // the current waypoint.
  // If the current waypoint is the first waypoint in the list (Vehicle.waypoint
  // or Trip.remaining_waypoints), then the starting point is the vehicle's
  // location recorded at the time this TripWaypoint was added to the list.
  google.protobuf.Int32Value distance_meters = 6;

  // The arrival time to this waypoint calculated by Fleet Engine.
  google.protobuf.Timestamp eta = 7;

  // The travel time from previous waypoint to this point.
  // If the current waypoint is the first waypoint in the list (Vehicle.waypoint
  // or Trip.remaining_waypoints), then the starting point is the vehicle's
  // location recorded at the time that this waypoint was added to the list.
  // This field is filled only when returning Trip/Vehicle data.
  google.protobuf.Duration duration = 8;
}

// The 'Status' defines a FleetEngine custom logical error mode.
message Status {
  // The canonical error code.
  enum Code {
    // Unspecified status, not a valid value to set.
    UNSPECIFIED = 0;

    // Internal server error. Usually expect the client to retry in this case.
    FAILURE = 1;

    // There is no possible route. Client should not retry.
    ROUTE_NOT_POSSIBLE = 2;
  }

  // The error code. It is not possible to have a value as 0 if it is explicitly
  // set by the server.
  Code code = 1;

  // Detailed error message.
  string message = 2;

  // A list of messages that carry the error details.  There is a common set of
  // message types for APIs to use.
  repeated google.protobuf.Any details = 3;
}

// A full, human-readable address for the entity containing this message.
message FormattedAddress {
  // The lines of text that describe the address.
  // At least one line must be present.
  repeated string lines = 1;
}

// Address of a place.
message Address {
  // A full, human-readable address for this place.
  FormattedAddress formatted_address = 1;
}

// Describes a vehicle attribute as a key-value pair.
message VehicleAttribute {
  // The attribute's key. Keys may not contain the colon character (:).
  string key = 1;

  // The attribute's value.
  string value = 2;
}

// The location, speed, and heading of a vehicle at a point in time.
message VehicleLocation {
  // The location of the vehicle.
  // When it is sent to FleetEngine, the vehicle's location is a GPS location.
  // When you receive it in a response, the vehicle's location can be either a
  // GPS location or a supplemental location. The source is specified in the
  // field 'location_sensor'.
  google.type.LatLng location = 1;

  // Deprecated. Use latlng_accuracy instead.
  google.protobuf.DoubleValue horizontal_accuracy = 8 [deprecated = true];

  // Accuracy of horizontal measurements (lat/lng) in meters as a radius.
  google.protobuf.DoubleValue latlng_accuracy = 22;

  // Direction the vehicle is moving in degrees.  0 represents North.
  // The valid range is [0,360).
  google.protobuf.Int32Value heading = 2;

  // Deprecated. Use heading_accuracy instead.
  google.protobuf.DoubleValue bearing_accuracy = 10 [deprecated = true];

  // Accuracy of heading (bearing) in degrees.
  google.protobuf.DoubleValue heading_accuracy = 23;

  // Altitude in meters above WGS84.
  google.protobuf.DoubleValue altitude = 5;

  // Deprecated. Use altitude_accurarcy instead.
  google.protobuf.DoubleValue vertical_accuracy = 9 [deprecated = true];

  // Accuracy of altitude measurement in meters.
  google.protobuf.DoubleValue altitude_accuracy = 24;

  // Speed of the vehicle in kilometers per hour.
  // Deprecated. Use speed instead.
  google.protobuf.Int32Value speed_kmph = 3 [deprecated = true];

  // Speed of the vehicle in meters/second
  google.protobuf.DoubleValue speed = 6;

  // Accuracy of speed in meters/second.
  google.protobuf.DoubleValue speed_accuracy = 7;

  // The time when the location was recorded.
  google.protobuf.Timestamp update_time = 4;

  // Output only. The time when the server receives the location information, filled by
  // FleetEngine.
  google.protobuf.Timestamp server_time = 13 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Provider of location data (for example, "gps").
  LocationSensor location_sensor = 11;

  // Whether the vehicle location given by "location" field is snapped to a road
  // closest to the location given by "raw_location".
  // Driver SDK 1.15.1/2.1.1 and up will always set this field.
  // Unset value will be treated as true.
  google.protobuf.BoolValue is_road_snapped = 27;

  // Input only. Indicates whether the GPS sensor is enabled.
  google.protobuf.BoolValue is_gps_sensor_enabled = 12 [(google.api.field_behavior) = INPUT_ONLY];

  // Input only. Time (in seconds) since this location sample was first sent to the server.
  // This will be zero for the first update. If the time is unknown
  // (for example, when the app restarts), this value resets to zero.
  google.protobuf.Int32Value time_since_update = 14 [(google.api.field_behavior) = INPUT_ONLY];

  // Input only. Number of additional attempts to send the current location to the server.
  // If this value is zero, then it is not stale.
  google.protobuf.Int32Value num_stale_updates = 15 [(google.api.field_behavior) = INPUT_ONLY];

  // Raw vehicle location (unprocessed by road-snapper).
  google.type.LatLng raw_location = 16;

  // Input only. Timestamp associated with the raw location.
  google.protobuf.Timestamp raw_location_time = 17 [(google.api.field_behavior) = INPUT_ONLY];

  // Input only. Source of the raw location.
  LocationSensor raw_location_sensor = 28 [(google.api.field_behavior) = INPUT_ONLY];

  // Input only. Accuracy of the raw location (lat/lng) as a radius, measured in meters.
  google.protobuf.DoubleValue raw_location_accuracy = 25 [(google.api.field_behavior) = INPUT_ONLY];

  // Input only. Supplemental location provided by the integrating app, such as the location
  // provided by Fused Location Provider.
  google.type.LatLng supplemental_location = 18 [(google.api.field_behavior) = INPUT_ONLY];

  // Input only. Timestamp associated with the supplemental location.
  google.protobuf.Timestamp supplemental_location_time = 19 [(google.api.field_behavior) = INPUT_ONLY];

  // Input only. Source of the supplemental location.
  LocationSensor supplemental_location_sensor = 20 [(google.api.field_behavior) = INPUT_ONLY];

  // Input only. Accuracy of supplemental location (lat/lng) as a radius, measured in
  // meters.
  google.protobuf.DoubleValue supplemental_location_accuracy = 21 [(google.api.field_behavior) = INPUT_ONLY];

  // Deprecated, use is_road_snapped instead.
  bool road_snapped = 26 [deprecated = true];
}

// The type of a trip.
enum TripType {
  // Default, used for unspecified or unrecognized trip types.
  UNKNOWN_TRIP_TYPE = 0;

  // The trip may share a vehicle with other trips.
  SHARED = 1;

  // The trip is exclusive to a vehicle.
  EXCLUSIVE = 2;
}

// The type of waypoint.
enum WaypointType {
  // Default, unknown waypoint type
  UNKNOWN_WAYPOINT_TYPE = 0;

  // Waypoints for picking up customers or merchandise.
  PICKUP_WAYPOINT_TYPE = 1;

  // Waypoints for dropping off customers or merchandise.
  DROP_OFF_WAYPOINT_TYPE = 2;

  // Waypoints for intermediate destinations in a multi-destination trip.
  INTERMEDIATE_DESTINATION_WAYPOINT_TYPE = 3;
}

// The type of polyline format.
enum PolylineFormatType {
  // Unspecified format type.
  UNKNOWN_FORMAT_TYPE = 0;

  // Repeated LatLng.
  LAT_LNG_LIST_TYPE = 1;

  // A polyline encoded with a polyline compression algorithm. Decoding is not
  // yet supported.
  ENCODED_POLYLINE_TYPE = 2;
}

// A set of values that specify the vehicle's navigation status.
enum NavigationStatus {
  // Unspecified navigation status.
  UNKNOWN_NAVIGATION_STATUS = 0;

  // The Driver app's navigation is in FREE_NAV mode.
  NO_GUIDANCE = 1;

  // Turn-by-turn navigation starts and the Driver app navigation enters
  // GUIDED_NAV mode showing the green header, route, and destination marker.
  ENROUTE_TO_DESTINATION = 2;

  // Vehicle has gone off the suggested route.
  OFF_ROUTE = 3;

  // The vehicle is within 50m of the destination and onArrival was
  // automatically triggered.
  ARRIVED_AT_DESTINATION = 4;
}

// Possible location providers.
enum LocationSensor {
  // Undefined sensor.
  UNKNOWN_SENSOR = 0;

  // Sensors: (GPS, AGPS).
  GPS = 1;

  // Sensors: (AGPS, CellID, WiFi MACID).
  NETWORK = 2;

  // Sensors: (CellID, WiFi MACID).
  PASSIVE = 3;

  // GMM's road snapped (gmfc) location.
  ROAD_SNAPPED_LOCATION_PROVIDER = 4;

  // Unspecified, but generated by the Fused Location Provider.
  FUSED_LOCATION_PROVIDER = 100;
}
