Skip to content

Commit bab2449

Browse files
Google APIscopybara-github
authored andcommitted
feat: Add ComputeCustomRoutes service and its request and response protos.
PiperOrigin-RevId: 373207098
1 parent 57970fa commit bab2449

7 files changed

Lines changed: 297 additions & 5 deletions

File tree

google/maps/routes/v1/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ load("//google/maps:postprocessing.bzl", "maps_assembly_pkg")
1313
proto_library(
1414
name = "routes_proto",
1515
srcs = [
16+
"compute_custom_routes_request.proto",
17+
"compute_custom_routes_response.proto",
1618
"compute_route_matrix_request.proto",
1719
"compute_routes_request.proto",
1820
"compute_routes_response.proto",
21+
"custom_route.proto",
1922
"fallback_info.proto",
2023
"polyline.proto",
2124
"route.proto",
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// Copyright 2021 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+
15+
syntax = "proto3";
16+
17+
package google.maps.routes.v1;
18+
19+
import "google/api/field_behavior.proto";
20+
import "google/maps/routes/v1/compute_routes_request.proto";
21+
import "google/maps/routes/v1/polyline.proto";
22+
import "google/maps/routes/v1/waypoint.proto";
23+
import "google/protobuf/timestamp.proto";
24+
25+
option cc_enable_arenas = true;
26+
option csharp_namespace = "Google.Maps.Routes.V1";
27+
option go_package = "google.golang.org/genproto/googleapis/maps/routes/v1;routes";
28+
option java_multiple_files = true;
29+
option java_outer_classname = "ComputeCustomRoutesRequestProto";
30+
option java_package = "com.google.maps.routes.v1";
31+
option objc_class_prefix = "GMRS";
32+
option php_namespace = "Google\\Maps\\Routes\\V1";
33+
34+
// ComputeCustomRoutes request message.
35+
message ComputeCustomRoutesRequest {
36+
// Required. Origin waypoint.
37+
Waypoint origin = 1 [(google.api.field_behavior) = REQUIRED];
38+
39+
// Required. Destination waypoint.
40+
Waypoint destination = 2 [(google.api.field_behavior) = REQUIRED];
41+
42+
// Optional. A set of waypoints along the route (excluding terminal points), for either
43+
// stopping at or passing by. Up to 25 intermediate waypoints are supported.
44+
// Intermediates are not supported in ComputeCustomRoutes Alpha.
45+
repeated Waypoint intermediates = 3 [(google.api.field_behavior) = OPTIONAL];
46+
47+
// Optional. Specifies the mode of transportation. Only DRIVE is supported in
48+
// ComputeCustomRoutes Alpha.
49+
RouteTravelMode travel_mode = 4 [(google.api.field_behavior) = OPTIONAL];
50+
51+
// Optional. Specifies how to compute the route. The server attempts to use the selected
52+
// routing preference to compute the route. If the routing preference results
53+
// in an error or an extra long latency, then an error is returned. In the
54+
// future, we might implement a fallback mechanism to use a different option
55+
// when the preferred option does not give a valid result. You can specify
56+
// this option only when the `travel_mode` is `DRIVE` or `TWO_WHEELER`,
57+
// otherwise the request fails.
58+
RoutingPreference routing_preference = 5 [(google.api.field_behavior) = OPTIONAL];
59+
60+
// Optional. Specifies your preference for the quality of the polyline.
61+
PolylineQuality polyline_quality = 6 [(google.api.field_behavior) = OPTIONAL];
62+
63+
// Optional. Specifies the preferred encoding for the polyline.
64+
PolylineEncoding polyline_encoding = 13 [(google.api.field_behavior) = OPTIONAL];
65+
66+
// Optional. The departure time. If you don't set this value, then this value
67+
// defaults to the time that you made the request. If you set this value to a
68+
// time that has already occurred, then the request fails.
69+
google.protobuf.Timestamp departure_time = 7 [(google.api.field_behavior) = OPTIONAL];
70+
71+
// Optional. A set of conditions to satisfy that affect the way routes are calculated.
72+
RouteModifiers route_modifiers = 11 [(google.api.field_behavior) = OPTIONAL];
73+
74+
// Required. A route objective to optimize for.
75+
RouteObjective route_objective = 12 [(google.api.field_behavior) = REQUIRED];
76+
77+
// Optional. The BCP-47 language code, such as "en-US" or "sr-Latn". For more
78+
// information, see
79+
// http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. See
80+
// [Language Support](https://developers.google.com/maps/faq#languagesupport)
81+
// for the list of supported languages. When you don't provide this value, the
82+
// display language is inferred from the location of the route request.
83+
string language_code = 9 [(google.api.field_behavior) = OPTIONAL];
84+
85+
// Optional. Specifies the units of measure for the display fields. This includes the
86+
// `instruction` field in `NavigationInstruction`. The units of measure used
87+
// for the route, leg, step distance, and duration are not affected by this
88+
// value. If you don't provide this value, then the display units are inferred
89+
// from the location of the request.
90+
Units units = 10 [(google.api.field_behavior) = OPTIONAL];
91+
}
92+
93+
// Encapsulates an objective to optimize for by ComputeCustomRoutes.
94+
message RouteObjective {
95+
// Encapsulates a RateCard route objective.
96+
message RateCard {
97+
// Encapsulates the cost used in the rate card.
98+
message MonetaryCost {
99+
// Required. The cost value in local currency inferred from the request.
100+
double value = 1 [(google.api.field_behavior) = REQUIRED];
101+
}
102+
103+
// Optional. Cost per minute.
104+
MonetaryCost cost_per_minute = 2 [(google.api.field_behavior) = OPTIONAL];
105+
106+
// Optional. Cost per kilometer.
107+
MonetaryCost cost_per_km = 3 [(google.api.field_behavior) = OPTIONAL];
108+
109+
// Optional. Whether to include toll cost in the overall cost.
110+
bool include_tolls = 4 [(google.api.field_behavior) = OPTIONAL];
111+
}
112+
113+
// The route objective.
114+
oneof objective {
115+
// The RateCard objective.
116+
RateCard rate_card = 1;
117+
}
118+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Copyright 2021 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+
15+
syntax = "proto3";
16+
17+
package google.maps.routes.v1;
18+
19+
import "google/maps/routes/v1/custom_route.proto";
20+
import "google/maps/routes/v1/fallback_info.proto";
21+
22+
option cc_enable_arenas = true;
23+
option csharp_namespace = "Google.Maps.Routes.V1";
24+
option go_package = "google.golang.org/genproto/googleapis/maps/routes/v1;routes";
25+
option java_multiple_files = true;
26+
option java_outer_classname = "ComputeCustomRoutesResponseProto";
27+
option java_package = "com.google.maps.routes.v1";
28+
option objc_class_prefix = "GMRS";
29+
option php_namespace = "Google\\Maps\\Routes\\V1";
30+
31+
// ComputeCustomRoutes response message.
32+
message ComputeCustomRoutesResponse {
33+
// Encapsulates fallback info for ComputeCustomRoutes. ComputeCustomRoutes
34+
// performs two types of fallbacks:
35+
//
36+
// 1. If it cannot compute the route using the routing_preference requested by
37+
// the customer, it will fallback to another routing mode. In this case
38+
// fallback_routing_mode and routing_mode_fallback_reason are used to
39+
// communicate the fallback routing mode used, as well as the reason for
40+
// fallback. Fallback of routing_preference is not supported in
41+
// ComputeCustomRoutes Alpha.
42+
//
43+
// 2. If it cannot compute a 'best' route for the route objective specified by
44+
// the customer, it might fallback to another objective.
45+
// fallback_route_objective is used to communicate the fallback route
46+
// objective.
47+
message FallbackInfo {
48+
// RouteObjective used for the response.
49+
enum FallbackRouteObjective {
50+
// Fallback route objective unspecified.
51+
FALLBACK_ROUTE_OBJECTIVE_UNSPECIFIED = 0;
52+
53+
// If customer requests RateCard and sets include_tolls to true, and
54+
// Google does not have toll price data for the route, the API falls back
55+
// to RateCard without considering toll price.
56+
FALLBACK_RATECARD_WITHOUT_TOLL_PRICE_DATA = 1;
57+
}
58+
59+
// Routing mode used for the response. If fallback was triggered, the mode
60+
// may be different from routing preference set in the original client
61+
// request.
62+
FallbackRoutingMode routing_mode = 1;
63+
64+
// The reason why fallback response was used instead of the original
65+
// response.
66+
// This field is only populated when the fallback mode is triggered and
67+
// the fallback response is returned.
68+
FallbackReason routing_mode_reason = 2;
69+
70+
// The route objective used for the response. If fallback was triggered, the
71+
// objective may be different from the route objective provided in the
72+
// original client request.
73+
FallbackRouteObjective route_objective = 3;
74+
}
75+
76+
// The ‘best’ routes for the input route objective.
77+
repeated CustomRoute routes = 7;
78+
79+
// The fastest reference route.
80+
CustomRoute fastest_route = 5;
81+
82+
// The shortest reference route.
83+
CustomRoute shortest_route = 6;
84+
85+
// Fallback info for custom routes.
86+
FallbackInfo fallback_info = 8;
87+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2021 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+
15+
syntax = "proto3";
16+
17+
package google.maps.routes.v1;
18+
19+
import "google/maps/routes/v1/route.proto";
20+
21+
option cc_enable_arenas = true;
22+
option csharp_namespace = "Google.Maps.Routes.V1";
23+
option go_package = "google.golang.org/genproto/googleapis/maps/routes/v1;routes";
24+
option java_multiple_files = true;
25+
option java_outer_classname = "CustomRouteProto";
26+
option java_package = "com.google.maps.routes.v1";
27+
option objc_class_prefix = "GMRS";
28+
option php_namespace = "Google\\Maps\\Routes\\V1";
29+
30+
// Encapsulates a custom route computed based on the route objective specified
31+
// by the customer. CustomRoute contains a route and a route token, which can be
32+
// passed to NavSDK to reconstruct the custom route for turn by turn navigation.
33+
message CustomRoute {
34+
// The route considered 'best' for the input route objective.
35+
Route route = 11;
36+
37+
// Web-safe base64 encoded route token that can be passed to NavSDK, which
38+
// allows NavSDK to reconstruct the route during navigation, and in the event
39+
// of rerouting honor the original intention when RoutesPreferred
40+
// ComputeCustomRoutes is called. Customers should treat this token as an
41+
// opaque blob.
42+
string token = 12;
43+
}

google/maps/routes/v1/route_service.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ syntax = "proto3";
1717
package google.maps.routes.v1;
1818

1919
import "google/api/annotations.proto";
20+
import "google/maps/routes/v1/compute_custom_routes_request.proto";
21+
import "google/maps/routes/v1/compute_custom_routes_response.proto";
2022
import "google/maps/routes/v1/compute_route_matrix_request.proto";
2123
import "google/maps/routes/v1/compute_routes_request.proto";
2224
import "google/maps/routes/v1/compute_routes_response.proto";

google/maps/routes/v1/routespreferred.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ authentication:
1717
oauth:
1818
canonical_scopes: |-
1919
https://www.googleapis.com/auth/maps-platform.routespreferred
20-
- selector: google.maps.routes.v1alpha.RoutesAlpha.ComputeRouteMatrix
21-
oauth:
22-
canonical_scopes: |-
23-
https://www.googleapis.com/auth/maps-platform.routespreferred
24-
- selector: google.maps.routes.v1alpha.RoutesAlpha.ComputeRoutes
20+
- selector: 'google.maps.routes.v1alpha.RoutesAlpha.*'
2521
oauth:
2622
canonical_scopes: |-
2723
https://www.googleapis.com/auth/maps-platform.routespreferred

google/maps/routes/v1alpha/route_service.proto

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ syntax = "proto3";
1717
package google.maps.routes.v1alpha;
1818

1919
import "google/api/annotations.proto";
20+
import "google/maps/routes/v1/compute_custom_routes_request.proto";
21+
import "google/maps/routes/v1/compute_custom_routes_response.proto";
2022
import "google/maps/routes/v1/compute_route_matrix_request.proto";
2123
import "google/maps/routes/v1/compute_routes_request.proto";
2224
import "google/maps/routes/v1/compute_routes_response.proto";
@@ -119,4 +121,45 @@ service RoutesAlpha {
119121
body: "*"
120122
};
121123
}
124+
125+
// Given a set of terminal and intermediate waypoints, and a route objective,
126+
// computes the best route for the route objective. Also returns fastest route
127+
// and shortest route as reference routes.
128+
//
129+
// **NOTE:** This method requires that you specify a response field mask in
130+
// the input. You can provide the response field mask by using the URL
131+
// parameter `$fields` or `fields`, or by using the HTTP/gRPC header
132+
// `X-Goog-FieldMask` (see the [available URL parameters and
133+
// headers](https://cloud.google.com/apis/docs/system-parameters). The value
134+
// is a comma separated list of field paths. See this detailed documentation
135+
// about [how to construct the field
136+
// paths](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto).
137+
//
138+
// For example, in this method:
139+
//
140+
// * Field mask of all available fields (for manual inspection):
141+
// `X-Goog-FieldMask: *`
142+
// * Field mask of route distances, durations, token and toll info:
143+
// `X-Goog-FieldMask:
144+
// routes.route.distanceMeters,routes.route.duration,routes.token,routes.route.travelAdvisory.tollInfo`
145+
//
146+
// Google discourages the use of the wildcard (`*`) response field mask, or
147+
// specifying the field mask at the top level (`routes`), because:
148+
//
149+
// * Selecting only the fields that you need helps our server save computation
150+
// cycles, allowing us to return the result to you with a lower latency.
151+
// * Selecting only the fields that you need in your production job ensures
152+
// stable latency performance. We might add more response fields in the
153+
// future, and those new fields might require extra computation time. If you
154+
// select all fields, or if you select all fields at the top level, then you
155+
// might experience performance degradation because any new field we add will
156+
// be automatically included in the response.
157+
// * Selecting only the fields that you need results in a smaller response
158+
// size, and thus higher network throughput.
159+
rpc ComputeCustomRoutes(google.maps.routes.v1.ComputeCustomRoutesRequest) returns (google.maps.routes.v1.ComputeCustomRoutesResponse) {
160+
option (google.api.http) = {
161+
post: "/v1alpha:computeCustomRoutes"
162+
body: "*"
163+
};
164+
}
122165
}

0 commit comments

Comments
 (0)