xref: /aosp_15_r20/external/googleapis/google/maps/routing/v2/routes_service.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 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
15syntax = "proto3";
16
17package google.maps.routing.v2;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/maps/routing/v2/fallback_info.proto";
23import "google/maps/routing/v2/geocoding_results.proto";
24import "google/maps/routing/v2/polyline.proto";
25import "google/maps/routing/v2/route.proto";
26import "google/maps/routing/v2/route_modifiers.proto";
27import "google/maps/routing/v2/route_travel_mode.proto";
28import "google/maps/routing/v2/routing_preference.proto";
29import "google/maps/routing/v2/traffic_model.proto";
30import "google/maps/routing/v2/transit_preferences.proto";
31import "google/maps/routing/v2/units.proto";
32import "google/maps/routing/v2/waypoint.proto";
33import "google/protobuf/duration.proto";
34import "google/protobuf/timestamp.proto";
35import "google/rpc/status.proto";
36import "google/type/localized_text.proto";
37
38option cc_enable_arenas = true;
39option csharp_namespace = "Google.Maps.Routing.V2";
40option go_package = "cloud.google.com/go/maps/routing/apiv2/routingpb;routingpb";
41option java_multiple_files = true;
42option java_outer_classname = "RoutesServiceProto";
43option java_package = "com.google.maps.routing.v2";
44option objc_class_prefix = "GMRV2";
45option php_namespace = "Google\\Maps\\Routing\\V2";
46option ruby_package = "Google::Maps::Routing::V2";
47
48// The Routes API.
49service Routes {
50  option (google.api.default_host) = "routes.googleapis.com";
51
52  // Returns the primary route along with optional alternate routes, given a set
53  // of terminal and intermediate waypoints.
54  //
55  // **NOTE:** This method requires that you specify a response field mask in
56  // the input. You can provide the response field mask by using URL parameter
57  // `$fields` or `fields`, or by using an HTTP/gRPC header `X-Goog-FieldMask`
58  // (see the [available URL parameters and
59  // headers](https://cloud.google.com/apis/docs/system-parameters)). The value
60  // is a comma separated list of field paths. See detailed documentation about
61  // [how to construct the field
62  // paths](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto).
63  //
64  // For example, in this method:
65  //
66  // * Field mask of all available fields (for manual inspection):
67  //   `X-Goog-FieldMask: *`
68  // * Field mask of Route-level duration, distance, and polyline (an example
69  // production setup):
70  //   `X-Goog-FieldMask:
71  //   routes.duration,routes.distanceMeters,routes.polyline.encodedPolyline`
72  //
73  // Google discourage the use of the wildcard (`*`) response field mask, or
74  // specifying the field mask at the top level (`routes`), because:
75  //
76  // * Selecting only the fields that you need helps our server save computation
77  // cycles, allowing us to return the result to you with a lower latency.
78  // * Selecting only the fields that you need
79  // in your production job ensures stable latency performance. We might add
80  // more response fields in the future, and those new fields might require
81  // extra computation time. If you select all fields, or if you select all
82  // fields at the top level, then you might experience performance degradation
83  // because any new field we add will be automatically included in the
84  // response.
85  // * Selecting only the fields that you need results in a smaller response
86  // size, and thus higher network throughput.
87  rpc ComputeRoutes(ComputeRoutesRequest) returns (ComputeRoutesResponse) {
88    option (google.api.http) = {
89      post: "/directions/v2:computeRoutes"
90      body: "*"
91    };
92  }
93
94  // Takes in a list of origins and destinations and returns a stream containing
95  // route information for each combination of origin and destination.
96  //
97  // **NOTE:** This method requires that you specify a response field mask in
98  // the input. You can provide the response field mask by using the URL
99  // parameter `$fields` or `fields`, or by using the HTTP/gRPC header
100  // `X-Goog-FieldMask` (see the [available URL parameters and
101  // headers](https://cloud.google.com/apis/docs/system-parameters)).
102  // The value is a comma separated list of field paths. See this detailed
103  // documentation about [how to construct the field
104  // paths](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto).
105  //
106  // For example, in this method:
107  //
108  // * Field mask of all available fields (for manual inspection):
109  //   `X-Goog-FieldMask: *`
110  // * Field mask of route durations, distances, element status, condition, and
111  //   element indices (an example production setup):
112  //   `X-Goog-FieldMask:
113  //   originIndex,destinationIndex,status,condition,distanceMeters,duration`
114  //
115  // It is critical that you include `status` in your field mask as otherwise
116  // all messages will appear to be OK. Google discourages the use of the
117  // wildcard (`*`) response field mask, because:
118  //
119  // * Selecting only the fields that you need helps our server save computation
120  // cycles, allowing us to return the result to you with a lower latency.
121  // * Selecting only the fields that you need in your production job ensures
122  // stable latency performance. We might add more response fields in the
123  // future, and those new fields might require extra computation time. If you
124  // select all fields, or if you select all fields at the top level, then you
125  // might experience performance degradation because any new field we add will
126  // be automatically included in the response.
127  // * Selecting only the fields that you need results in a smaller response
128  // size, and thus higher network throughput.
129  rpc ComputeRouteMatrix(ComputeRouteMatrixRequest)
130      returns (stream RouteMatrixElement) {
131    option (google.api.http) = {
132      post: "/distanceMatrix/v2:computeRouteMatrix"
133      body: "*"
134    };
135  }
136}
137
138// ComputeRoutes request message.
139message ComputeRoutesRequest {
140  // A supported reference route on the ComputeRoutesRequest.
141  enum ReferenceRoute {
142    // Not used. Requests containing this value fail.
143    REFERENCE_ROUTE_UNSPECIFIED = 0;
144
145    // Fuel efficient route. Routes labeled with this value are determined to be
146    // optimized for parameters such as fuel consumption.
147    FUEL_EFFICIENT = 1;
148  }
149
150  // Extra computations to perform while completing the request.
151  enum ExtraComputation {
152    // Not used. Requests containing this value will fail.
153    EXTRA_COMPUTATION_UNSPECIFIED = 0;
154
155    // Toll information for the route(s).
156    TOLLS = 1;
157
158    // Estimated fuel consumption for the route(s).
159    FUEL_CONSUMPTION = 2;
160
161    // Traffic aware polylines for the route(s).
162    TRAFFIC_ON_POLYLINE = 3;
163
164    // [`NavigationInstructions`](google.maps.routing.v2.NavigationInstructions.instructions)
165    // presented as a formatted HTML text string. This content
166    // is meant to be read as-is. This content is for display only.
167    // Do not programmatically parse it.
168    HTML_FORMATTED_NAVIGATION_INSTRUCTIONS = 4;
169  }
170
171  // Required. Origin waypoint.
172  Waypoint origin = 1 [(google.api.field_behavior) = REQUIRED];
173
174  // Required. Destination waypoint.
175  Waypoint destination = 2 [(google.api.field_behavior) = REQUIRED];
176
177  // Optional. A set of waypoints along the route (excluding terminal points),
178  // for either stopping at or passing by. Up to 25 intermediate waypoints are
179  // supported.
180  repeated Waypoint intermediates = 3 [(google.api.field_behavior) = OPTIONAL];
181
182  // Optional. Specifies the mode of transportation.
183  RouteTravelMode travel_mode = 4 [(google.api.field_behavior) = OPTIONAL];
184
185  // Optional. Specifies how to compute the route. The server
186  // attempts to use the selected routing preference to compute the route. If
187  //  the routing preference results in an error or an extra long latency, then
188  // an error is returned. You can specify this option only when the
189  // `travel_mode` is `DRIVE` or `TWO_WHEELER`, otherwise the request fails.
190  RoutingPreference routing_preference = 5
191      [(google.api.field_behavior) = OPTIONAL];
192
193  // Optional. Specifies your preference for the quality of the polyline.
194  PolylineQuality polyline_quality = 6 [(google.api.field_behavior) = OPTIONAL];
195
196  // Optional. Specifies the preferred encoding for the polyline.
197  PolylineEncoding polyline_encoding = 12
198      [(google.api.field_behavior) = OPTIONAL];
199
200  // Optional. The departure time. If you don't set this value, then this value
201  // defaults to the time that you made the request.
202  // NOTE: You can only specify a `departure_time` in the past when
203  // [`RouteTravelMode`][google.maps.routing.v2.RouteTravelMode] is set to
204  // `TRANSIT`. Transit trips are available for up to 7 days in the past or 100
205  // days in the future.
206  google.protobuf.Timestamp departure_time = 7
207      [(google.api.field_behavior) = OPTIONAL];
208
209  // Optional. The arrival time.
210  // NOTE: Can only be set when
211  // [RouteTravelMode][google.maps.routing.v2.RouteTravelMode] is set to
212  // `TRANSIT`. You can specify either `departure_time` or `arrival_time`, but
213  // not both. Transit trips are available for up to 7 days in the past or 100
214  // days in the future.
215  google.protobuf.Timestamp arrival_time = 19
216      [(google.api.field_behavior) = OPTIONAL];
217
218  // Optional. Specifies whether to calculate alternate routes in addition to
219  // the route. No alternative routes are returned for requests that have
220  // intermediate waypoints.
221  bool compute_alternative_routes = 8 [(google.api.field_behavior) = OPTIONAL];
222
223  // Optional. A set of conditions to satisfy that affect the way routes are
224  // calculated.
225  RouteModifiers route_modifiers = 9 [(google.api.field_behavior) = OPTIONAL];
226
227  // Optional. The BCP-47 language code, such as "en-US" or "sr-Latn". For more
228  // information, see [Unicode Locale
229  // Identifier](http://www.unicode.org/reports/tr35/#Unicode_locale_identifier).
230  // See [Language
231  // Support](https://developers.google.com/maps/faq#languagesupport)
232  // for the list of supported languages. When you don't provide this value, the
233  // display language is inferred from the location of the route request.
234  string language_code = 10 [(google.api.field_behavior) = OPTIONAL];
235
236  // Optional. The region code, specified as a ccTLD ("top-level domain")
237  // two-character value. For more information see [Country code top-level
238  // domains](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains).
239  string region_code = 16 [(google.api.field_behavior) = OPTIONAL];
240
241  // Optional. Specifies the units of measure for the display fields. These
242  // fields include the `instruction` field in
243  // [`NavigationInstruction`][google.maps.routing.v2.NavigationInstruction].
244  // The units of measure used for the route, leg, step distance, and duration
245  // are not affected by this value. If you don't provide this value, then the
246  // display units are inferred from the location of the first origin.
247  Units units = 11 [(google.api.field_behavior) = OPTIONAL];
248
249  // Optional. If set to true, the service attempts to minimize the overall cost
250  // of the route by re-ordering the specified intermediate waypoints. The
251  // request fails if any of the intermediate waypoints is a `via` waypoint. Use
252  // `ComputeRoutesResponse.Routes.optimized_intermediate_waypoint_index` to
253  // find the new ordering.
254  // If `ComputeRoutesResponseroutes.optimized_intermediate_waypoint_index` is
255  // not requested in the `X-Goog-FieldMask` header, the request fails.
256  // If `optimize_waypoint_order` is set to false,
257  // `ComputeRoutesResponse.optimized_intermediate_waypoint_index` will be
258  // empty.
259  bool optimize_waypoint_order = 13 [(google.api.field_behavior) = OPTIONAL];
260
261  // Optional. Specifies what reference routes to calculate as part of the
262  // request in addition to the default route. A reference route is a route with
263  // a different route calculation objective than the default route. For example
264  // a `FUEL_EFFICIENT` reference route calculation takes into account various
265  // parameters that would generate an optimal fuel efficient route.
266  repeated ReferenceRoute requested_reference_routes = 14
267      [(google.api.field_behavior) = OPTIONAL];
268
269  // Optional. A list of extra computations which may be used to complete the
270  // request. Note: These extra computations may return extra fields on the
271  // response. These extra fields must also be specified in the field mask to be
272  // returned in the response.
273  repeated ExtraComputation extra_computations = 15
274      [(google.api.field_behavior) = OPTIONAL];
275
276  // Optional. Specifies the assumptions to use when calculating time in
277  // traffic. This setting affects the value returned in the duration field in
278  // the
279  // [`Route`][google.maps.routing.v2.Route] and
280  // [`RouteLeg`][google.maps.routing.v2.RouteLeg] which contains the predicted
281  // time in traffic based on historical averages.
282  // `TrafficModel` is only available for requests that have set
283  // [`RoutingPreference`][google.maps.routing.v2.RoutingPreference] to
284  // `TRAFFIC_AWARE_OPTIMAL` and
285  // [`RouteTravelMode`][google.maps.routing.v2.RouteTravelMode] to `DRIVE`.
286  // Defaults to `BEST_GUESS` if traffic is requested and `TrafficModel` is not
287  // specified.
288  TrafficModel traffic_model = 18 [(google.api.field_behavior) = OPTIONAL];
289
290  // Optional. Specifies preferences that influence the route returned for
291  // `TRANSIT` routes. NOTE: You can only specify a `transit_preferences` when
292  // [`RouteTravelMode`][google.maps.routing.v2.RouteTravelMode] is set to
293  // `TRANSIT`.
294  TransitPreferences transit_preferences = 20
295      [(google.api.field_behavior) = OPTIONAL];
296}
297
298// ComputeRoutes the response message.
299message ComputeRoutesResponse {
300  // Contains an array of computed routes (up to three) when you specify
301  // `compute_alternatives_routes`, and contains just one route when you don't.
302  // When this array contains multiple entries, the first one is the most
303  // recommended route. If the array is empty, then it means no route could be
304  // found.
305  repeated Route routes = 1;
306
307  // In some cases when the server is not able to compute the route results with
308  // all of the input preferences, it may fallback to using a different way of
309  // computation. When fallback mode is used, this field contains detailed info
310  // about the fallback response. Otherwise this field is unset.
311  FallbackInfo fallback_info = 2;
312
313  // Contains geocoding response info for waypoints specified as addresses.
314  GeocodingResults geocoding_results = 3;
315}
316
317// ComputeRouteMatrix request message
318message ComputeRouteMatrixRequest {
319  // Extra computations to perform while completing the request.
320  enum ExtraComputation {
321    // Not used. Requests containing this value will fail.
322    EXTRA_COMPUTATION_UNSPECIFIED = 0;
323
324    // Toll information for the matrix element(s).
325    TOLLS = 1;
326  }
327
328  // Required. Array of origins, which determines the rows of the response
329  // matrix. Several size restrictions apply to the cardinality of origins and
330  // destinations:
331  //
332  // * The sum of the number of origins + the number of destinations specified
333  // as either `place_id` or `address` must be no greater than 50.
334  // * The product of number of origins × number of destinations must be no
335  // greater than 625 in any case.
336  // * The product of the number of origins × number of destinations must be no
337  // greater than 100 if routing_preference is set to `TRAFFIC_AWARE_OPTIMAL`.
338  // * The product of the number of origins × number of destinations must be no
339  // greater than 100 if travel_mode is set to `TRANSIT`.
340  repeated RouteMatrixOrigin origins = 1
341      [(google.api.field_behavior) = REQUIRED];
342
343  // Required. Array of destinations, which determines the columns of the
344  // response matrix.
345  repeated RouteMatrixDestination destinations = 2
346      [(google.api.field_behavior) = REQUIRED];
347
348  // Optional. Specifies the mode of transportation.
349  RouteTravelMode travel_mode = 3 [(google.api.field_behavior) = OPTIONAL];
350
351  // Optional. Specifies how to compute the route. The server attempts to use
352  // the selected routing preference to compute the route. If the routing
353  // preference results in an error or an extra long latency, an error is
354  // returned. You can specify this option only when the `travel_mode` is
355  // `DRIVE` or `TWO_WHEELER`, otherwise the request fails.
356  RoutingPreference routing_preference = 4
357      [(google.api.field_behavior) = OPTIONAL];
358
359  // Optional. The departure time. If you don't set this value, then this value
360  // defaults to the time that you made the request.
361  // NOTE: You can only specify a `departure_time` in the past when
362  // [`RouteTravelMode`][google.maps.routing.v2.RouteTravelMode] is set to
363  // `TRANSIT`.
364  google.protobuf.Timestamp departure_time = 5
365      [(google.api.field_behavior) = OPTIONAL];
366
367  // Optional. The arrival time.
368  // NOTE: Can only be set when
369  // [`RouteTravelMode`][google.maps.routing.v2.RouteTravelMode] is set to
370  // `TRANSIT`. You can specify either `departure_time` or `arrival_time`, but
371  // not both.
372  google.protobuf.Timestamp arrival_time = 11
373      [(google.api.field_behavior) = OPTIONAL];
374
375  // Optional. The BCP-47 language code, such as "en-US" or "sr-Latn". For more
376  // information, see [Unicode Locale
377  // Identifier](http://www.unicode.org/reports/tr35/#Unicode_locale_identifier).
378  // See [Language
379  // Support](https://developers.google.com/maps/faq#languagesupport)
380  // for the list of supported languages. When you don't provide this value, the
381  // display language is inferred from the location of the first origin.
382  string language_code = 6 [(google.api.field_behavior) = OPTIONAL];
383
384  // Optional. The region code, specified as a ccTLD ("top-level domain")
385  // two-character value. For more information see [Country code top-level
386  // domains](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains).
387  string region_code = 9 [(google.api.field_behavior) = OPTIONAL];
388
389  // Optional. Specifies the units of measure for the display fields.
390  Units units = 7 [(google.api.field_behavior) = OPTIONAL];
391
392  // Optional. A list of extra computations which may be used to complete the
393  // request. Note: These extra computations may return extra fields on the
394  // response. These extra fields must also be specified in the field mask to be
395  // returned in the response.
396  repeated ExtraComputation extra_computations = 8
397      [(google.api.field_behavior) = OPTIONAL];
398
399  // Optional. Specifies the assumptions to use when calculating time in
400  // traffic. This setting affects the value returned in the duration field in
401  // the [RouteMatrixElement][google.maps.routing.v2.RouteMatrixElement] which
402  // contains the predicted time in traffic based on historical averages.
403  // [RoutingPreference][google.maps.routing.v2.RoutingPreference] to
404  // `TRAFFIC_AWARE_OPTIMAL` and
405  // [RouteTravelMode][google.maps.routing.v2.RouteTravelMode] to `DRIVE`.
406  // Defaults to `BEST_GUESS` if traffic is requested and `TrafficModel` is not
407  // specified.
408  TrafficModel traffic_model = 10 [(google.api.field_behavior) = OPTIONAL];
409
410  // Optional. Specifies preferences that influence the route returned for
411  // `TRANSIT` routes. NOTE: You can only specify a `transit_preferences` when
412  // [RouteTravelMode][google.maps.routing.v2.RouteTravelMode] is set to
413  // `TRANSIT`.
414  TransitPreferences transit_preferences = 12
415      [(google.api.field_behavior) = OPTIONAL];
416}
417
418// A single origin for ComputeRouteMatrixRequest
419message RouteMatrixOrigin {
420  // Required. Origin waypoint
421  Waypoint waypoint = 1 [(google.api.field_behavior) = REQUIRED];
422
423  // Optional. Modifiers for every route that takes this as the origin
424  RouteModifiers route_modifiers = 2 [(google.api.field_behavior) = OPTIONAL];
425}
426
427// A single destination for ComputeRouteMatrixRequest
428message RouteMatrixDestination {
429  // Required. Destination waypoint
430  Waypoint waypoint = 1 [(google.api.field_behavior) = REQUIRED];
431}
432
433// Contains route information computed for an origin/destination pair in the
434// ComputeRouteMatrix API. This proto can be streamed to the client.
435message RouteMatrixElement {
436  // Text representations of certain properties.
437  message LocalizedValues {
438    // Travel distance represented in text form.
439    google.type.LocalizedText distance = 1;
440
441    // Duration represented in text form taking traffic conditions into
442    // consideration. Note: If traffic information was not requested, this value
443    // is the same value as static_duration.
444    google.type.LocalizedText duration = 2;
445
446    // Duration represented in text form without taking traffic conditions into
447    // consideration.
448    google.type.LocalizedText static_duration = 3;
449
450    // Transit fare represented in text form.
451    google.type.LocalizedText transit_fare = 4;
452  }
453
454  // Zero-based index of the origin in the request.
455  optional int32 origin_index = 1;
456
457  // Zero-based index of the destination in the request.
458  optional int32 destination_index = 2;
459
460  // Error status code for this element.
461  google.rpc.Status status = 3;
462
463  // Indicates whether the route was found or not. Independent of status.
464  RouteMatrixElementCondition condition = 9;
465
466  // The travel distance of the route, in meters.
467  int32 distance_meters = 4;
468
469  // The length of time needed to navigate the route. If you set the
470  // [routing_preference][google.maps.routing.v2.ComputeRouteMatrixRequest.routing_preference]
471  // to `TRAFFIC_UNAWARE`, then this value is the same as `static_duration`. If
472  // you set the `routing_preference` to either `TRAFFIC_AWARE` or
473  // `TRAFFIC_AWARE_OPTIMAL`, then this value is calculated taking traffic
474  // conditions into account.
475  google.protobuf.Duration duration = 5;
476
477  // The duration of traveling through the route without taking traffic
478  // conditions into consideration.
479  google.protobuf.Duration static_duration = 6;
480
481  // Additional information about the route. For example: restriction
482  // information and toll information
483  RouteTravelAdvisory travel_advisory = 7;
484
485  // In some cases when the server is not able to compute the route with the
486  // given preferences for this particular origin/destination pair, it may
487  // fall back to using a different mode of computation. When fallback mode is
488  // used, this field contains detailed information about the fallback response.
489  // Otherwise this field is unset.
490  FallbackInfo fallback_info = 8;
491
492  // Text representations of properties of the `RouteMatrixElement`.
493  LocalizedValues localized_values = 10;
494}
495
496// The condition of the route being returned.
497enum RouteMatrixElementCondition {
498  // Only used when the `status` of the element is not OK.
499  ROUTE_MATRIX_ELEMENT_CONDITION_UNSPECIFIED = 0;
500
501  // A route was found, and the corresponding information was filled out for the
502  // element.
503  ROUTE_EXISTS = 1;
504
505  // No route could be found. Fields containing route information, such as
506  // `distance_meters` or `duration`, will not be filled out in the element.
507  ROUTE_NOT_FOUND = 2;
508}
509