routes_service.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.maps.routing.v2;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/maps/routing/v2/fallback_info.proto";
  20. import "google/maps/routing/v2/polyline.proto";
  21. import "google/maps/routing/v2/route.proto";
  22. import "google/maps/routing/v2/route_modifiers.proto";
  23. import "google/maps/routing/v2/route_travel_mode.proto";
  24. import "google/maps/routing/v2/routing_preference.proto";
  25. import "google/maps/routing/v2/units.proto";
  26. import "google/maps/routing/v2/waypoint.proto";
  27. import "google/protobuf/duration.proto";
  28. import "google/protobuf/timestamp.proto";
  29. import "google/rpc/status.proto";
  30. option cc_enable_arenas = true;
  31. option csharp_namespace = "Google.Maps.Routing.V2";
  32. option go_package = "google.golang.org/genproto/googleapis/maps/routing/v2;routing";
  33. option java_multiple_files = true;
  34. option java_outer_classname = "RoutesServiceProto";
  35. option java_package = "com.google.maps.routing.v2";
  36. option objc_class_prefix = "GMRV2";
  37. option php_namespace = "Google\\Maps\\Routing\\V2";
  38. option ruby_package = "Google::Maps::Routing::V2";
  39. // The Routes API.
  40. service Routes {
  41. option (google.api.default_host) = "routes.googleapis.com";
  42. // Returns the primary route along with optional alternate routes, given a set
  43. // of terminal and intermediate waypoints.
  44. //
  45. // **NOTE:** This method requires that you specify a response field mask in
  46. // the input. You can provide the response field mask by using URL parameter
  47. // `$fields` or `fields`, or by using an HTTP/gRPC header `X-Goog-FieldMask`
  48. // (see the [available URL parameters and
  49. // headers](https://cloud.google.com/apis/docs/system-parameters). The value
  50. // is a comma separated list of field paths. See detailed documentation about
  51. // [how to construct the field
  52. // paths](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto).
  53. //
  54. // For example, in this method:
  55. //
  56. // * Field mask of all available fields (for manual inspection):
  57. // `X-Goog-FieldMask: *`
  58. // * Field mask of Route-level duration, distance, and polyline (an example
  59. // production setup):
  60. // `X-Goog-FieldMask:
  61. // routes.duration,routes.distanceMeters,routes.polyline.encodedPolyline`
  62. //
  63. // Google discourage the use of the wildcard (`*`) response field mask, or
  64. // specifying the field mask at the top level (`routes`), because:
  65. //
  66. // * Selecting only the fields that you need helps our server save computation
  67. // cycles, allowing us to return the result to you with a lower latency.
  68. // * Selecting only the fields that you need
  69. // in your production job ensures stable latency performance. We might add
  70. // more response fields in the future, and those new fields might require
  71. // extra computation time. If you select all fields, or if you select all
  72. // fields at the top level, then you might experience performance degradation
  73. // because any new field we add will be automatically included in the
  74. // response.
  75. // * Selecting only the fields that you need results in a smaller response
  76. // size, and thus higher network throughput.
  77. rpc ComputeRoutes(ComputeRoutesRequest) returns (ComputeRoutesResponse) {
  78. option (google.api.http) = {
  79. post: "/directions/v2:computeRoutes"
  80. body: "*"
  81. };
  82. }
  83. // Takes in a list of origins and destinations and returns a stream containing
  84. // route information for each combination of origin and destination.
  85. //
  86. // **NOTE:** This method requires that you specify a response field mask in
  87. // the input. You can provide the response field mask by using the URL
  88. // parameter `$fields` or `fields`, or by using the HTTP/gRPC header
  89. // `X-Goog-FieldMask` (see the [available URL parameters and
  90. // headers](https://cloud.google.com/apis/docs/system-parameters). The value
  91. // is a comma separated list of field paths. See this detailed documentation
  92. // about [how to construct the field
  93. // paths](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto).
  94. //
  95. // For example, in this method:
  96. //
  97. // * Field mask of all available fields (for manual inspection):
  98. // `X-Goog-FieldMask: *`
  99. // * Field mask of route durations, distances, element status, condition, and
  100. // element indices (an example production setup):
  101. // `X-Goog-FieldMask:
  102. // originIndex,destinationIndex,status,condition,distanceMeters,duration`
  103. //
  104. // It is critical that you include `status` in your field mask as otherwise
  105. // all messages will appear to be OK. Google discourages the use of the
  106. // wildcard (`*`) response field mask, because:
  107. //
  108. // * Selecting only the fields that you need helps our server save computation
  109. // cycles, allowing us to return the result to you with a lower latency.
  110. // * Selecting only the fields that you need in your production job ensures
  111. // stable latency performance. We might add more response fields in the
  112. // future, and those new fields might require extra computation time. If you
  113. // select all fields, or if you select all fields at the top level, then you
  114. // might experience performance degradation because any new field we add will
  115. // be automatically included in the response.
  116. // * Selecting only the fields that you need results in a smaller response
  117. // size, and thus higher network throughput.
  118. rpc ComputeRouteMatrix(ComputeRouteMatrixRequest) returns (stream RouteMatrixElement) {
  119. option (google.api.http) = {
  120. post: "/distanceMatrix/v2:computeRouteMatrix"
  121. body: "*"
  122. };
  123. }
  124. }
  125. // ComputeRoutes request message.
  126. message ComputeRoutesRequest {
  127. // A supported reference route on the ComputeRoutesRequest.
  128. enum ReferenceRoute {
  129. // Not used. Requests containing this value fail.
  130. REFERENCE_ROUTE_UNSPECIFIED = 0;
  131. // Fuel efficient route. Routes labeled with this value are determined to be
  132. // optimized for parameters such as fuel consumption.
  133. FUEL_EFFICIENT = 1;
  134. }
  135. // Required. Origin waypoint.
  136. Waypoint origin = 1 [(google.api.field_behavior) = REQUIRED];
  137. // Required. Destination waypoint.
  138. Waypoint destination = 2 [(google.api.field_behavior) = REQUIRED];
  139. // Optional. A set of waypoints along the route (excluding terminal points),
  140. // for either stopping at or passing by. Up to 25 intermediate waypoints are
  141. // supported.
  142. repeated Waypoint intermediates = 3 [(google.api.field_behavior) = OPTIONAL];
  143. // Optional. Specifies the mode of transportation.
  144. RouteTravelMode travel_mode = 4 [(google.api.field_behavior) = OPTIONAL];
  145. // Optional. Specifies how to compute the route. The server
  146. // attempts to use the selected routing preference to compute the route. If
  147. // the routing preference results in an error or an extra long latency, then
  148. // an error is returned. In the future, we might implement a fallback
  149. // mechanism to use a different option when the preferred option does not give
  150. // a valid result. You can specify this option only when the `travel_mode` is
  151. // `DRIVE` or `TWO_WHEELER`, otherwise the request fails.
  152. RoutingPreference routing_preference = 5 [(google.api.field_behavior) = OPTIONAL];
  153. // Optional. Specifies your preference for the quality of the polyline.
  154. PolylineQuality polyline_quality = 6 [(google.api.field_behavior) = OPTIONAL];
  155. // Optional. Specifies the preferred encoding for the polyline.
  156. PolylineEncoding polyline_encoding = 12 [(google.api.field_behavior) = OPTIONAL];
  157. // Optional. The departure time. If you don't set this value, then this value
  158. // defaults to the time that you made the request. If you set this value to a
  159. // time that has already occurred, then the request fails.
  160. google.protobuf.Timestamp departure_time = 7 [(google.api.field_behavior) = OPTIONAL];
  161. // Optional. Specifies whether to calculate alternate routes in addition to the route.
  162. bool compute_alternative_routes = 8 [(google.api.field_behavior) = OPTIONAL];
  163. // Optional. A set of conditions to satisfy that affect the way routes are
  164. // calculated.
  165. RouteModifiers route_modifiers = 9 [(google.api.field_behavior) = OPTIONAL];
  166. // Optional. The BCP-47 language code, such as "en-US" or "sr-Latn". For more
  167. // information, see
  168. // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. See
  169. // [Language Support](https://developers.google.com/maps/faq#languagesupport)
  170. // for the list of supported languages. When you don't provide this value, the
  171. // display language is inferred from the location of the route request.
  172. string language_code = 10 [(google.api.field_behavior) = OPTIONAL];
  173. // Optional. Specifies the units of measure for the display fields. This
  174. // includes the `instruction` field in `NavigationInstruction`. The units of
  175. // measure used for the route, leg, step distance, and duration are not
  176. // affected by this value. If you don't provide this value, then the display
  177. // units are inferred from the location of the request.
  178. Units units = 11 [(google.api.field_behavior) = OPTIONAL];
  179. // Optional. Specifies what reference routes to calculate as part of the request in
  180. // addition to the default route.
  181. // A reference route is a route with a different route calculation objective
  182. // than the default route. For example an FUEL_EFFICIENT reference route
  183. // calculation takes into account various parameters that would generate an
  184. // optimal fuel efficient route.
  185. repeated ReferenceRoute requested_reference_routes = 14 [(google.api.field_behavior) = OPTIONAL];
  186. }
  187. // ComputeRoutes the response message.
  188. message ComputeRoutesResponse {
  189. // Contains an array of computed routes (up to three) when you specify
  190. // compute_alternatives_routes, and contains just one route when you don't.
  191. // When this array contains multiple entries, the first one is the most
  192. // recommended route. If the array is empty, then it means no route could be
  193. // found.
  194. repeated Route routes = 1;
  195. // In some cases when the server is not able to compute the route results with
  196. // all of the input preferences, it may fallback to using a different way of
  197. // computation. When fallback mode is used, this field contains detailed info
  198. // about the fallback response. Otherwise this field is unset.
  199. FallbackInfo fallback_info = 2;
  200. }
  201. // ComputeRouteMatrix request message
  202. message ComputeRouteMatrixRequest {
  203. // Required. Array of origins, which determines the rows of the response matrix.
  204. // Several size restrictions apply to the cardinality of origins and
  205. // destinations:
  206. //
  207. // * The number of elements (origins × destinations) must be no greater than
  208. // 625 in any case.
  209. // * The number of elements (origins × destinations) must be no greater than
  210. // 100 if routing_preference is set to `TRAFFIC_AWARE_OPTIMAL`.
  211. // * The number of waypoints (origins + destinations) specified as `place_id`
  212. // must be no greater than 50.
  213. repeated RouteMatrixOrigin origins = 1 [(google.api.field_behavior) = REQUIRED];
  214. // Required. Array of destinations, which determines the columns of the response matrix.
  215. repeated RouteMatrixDestination destinations = 2 [(google.api.field_behavior) = REQUIRED];
  216. // Optional. Specifies the mode of transportation.
  217. RouteTravelMode travel_mode = 3 [(google.api.field_behavior) = OPTIONAL];
  218. // Optional. Specifies how to compute the route. The server attempts to use the selected
  219. // routing preference to compute the route. If the routing preference results
  220. // in an error or an extra long latency, an error is returned. In the future,
  221. // we might implement a fallback mechanism to use a different option when the
  222. // preferred option does not give a valid result. You can specify this option
  223. // only when the `travel_mode` is `DRIVE` or `TWO_WHEELER`, otherwise the
  224. // request fails.
  225. RoutingPreference routing_preference = 4 [(google.api.field_behavior) = OPTIONAL];
  226. // Optional. The departure time. If you don't set this value, this defaults to the time
  227. // that you made the request. If you set this value to a time that has already
  228. // occurred, the request fails.
  229. google.protobuf.Timestamp departure_time = 5 [(google.api.field_behavior) = OPTIONAL];
  230. }
  231. // A single origin for ComputeRouteMatrixRequest
  232. message RouteMatrixOrigin {
  233. // Required. Origin waypoint
  234. Waypoint waypoint = 1 [(google.api.field_behavior) = REQUIRED];
  235. // Optional. Modifiers for every route that takes this as the origin
  236. RouteModifiers route_modifiers = 2 [(google.api.field_behavior) = OPTIONAL];
  237. }
  238. // A single destination for ComputeRouteMatrixRequest
  239. message RouteMatrixDestination {
  240. // Required. Destination waypoint
  241. Waypoint waypoint = 1 [(google.api.field_behavior) = REQUIRED];
  242. }
  243. // Encapsulates route information computed for an origin/destination pair in the
  244. // ComputeRouteMatrix API. This proto can be streamed to the client.
  245. message RouteMatrixElement {
  246. // Zero-based index of the origin in the request.
  247. optional int32 origin_index = 1;
  248. // Zero-based index of the destination in the request.
  249. optional int32 destination_index = 2;
  250. // Error status code for this element.
  251. google.rpc.Status status = 3;
  252. // Indicates whether the route was found or not. Independent of status.
  253. RouteMatrixElementCondition condition = 9;
  254. // The travel distance of the route, in meters.
  255. int32 distance_meters = 4;
  256. // The length of time needed to navigate the route. If you set the
  257. // `routing_preference` to `TRAFFIC_UNAWARE`, then this value is the same as
  258. // `static_duration`. If you set the `routing_preference` to either
  259. // `TRAFFIC_AWARE` or `TRAFFIC_AWARE_OPTIMAL`, then this value is calculated
  260. // taking traffic conditions into account.
  261. google.protobuf.Duration duration = 5;
  262. // The duration of traveling through the route without taking traffic
  263. // conditions into consideration.
  264. google.protobuf.Duration static_duration = 6;
  265. // Additional information about the route. For example: restriction
  266. // information and toll information
  267. RouteTravelAdvisory travel_advisory = 7;
  268. // In some cases when the server is not able to compute the route with the
  269. // given preferences for this particular origin/destination pair, it may
  270. // fall back to using a different mode of computation. When fallback mode is
  271. // used, this field contains detailed information about the fallback response.
  272. // Otherwise this field is unset.
  273. FallbackInfo fallback_info = 8;
  274. }
  275. // The condition of the route being returned.
  276. enum RouteMatrixElementCondition {
  277. // Only used when the `status` of the element is not OK.
  278. ROUTE_MATRIX_ELEMENT_CONDITION_UNSPECIFIED = 0;
  279. // A route was found, and the corresponding information was filled out for the
  280. // element.
  281. ROUTE_EXISTS = 1;
  282. // No route could be found. Fields containing route information, such as
  283. // `distance_meters` or `duration`, will not be filled out in the element.
  284. ROUTE_NOT_FOUND = 2;
  285. }