Skip to content

Commit 680bcbb

Browse files
feat: [MapsRouteOptimization] add experimental Load Costs feature (#8662)
* feat: add experimental Load Costs feature feat: add experimental U-turn Avoidance feature feat: add OptimizeToursLongRunning method feat: add OptimizeToursUri method docs: A comment for field `duration_distance_matrices` in message `.google.maps.routeoptimization.v1.ShipmentModel` is changed docs: A comment for field `precedence_rules` in message `.google.maps.routeoptimization.v1.ShipmentModel` is changed docs: A comment for enum `TravelMode` is changed docs: A comment for field `place_id` in message `.google.maps.routeoptimization.v1.Waypoint` is changed PiperOrigin-RevId: 819788002 Source-Link: googleapis/googleapis@4c5d582 Source-Link: googleapis/googleapis-gen@f3bff08 Copy-Tag: eyJwIjoiTWFwc1JvdXRlT3B0aW1pemF0aW9uLy5Pd2xCb3QueWFtbCIsImgiOiJmM2JmZjA4OGYzNTllYWQ0ZTU4YTc2NTk5Mjc0MmZjYTRhNWZlZmY5In0= * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 1237077 commit 680bcbb

32 files changed

Lines changed: 2889 additions & 13 deletions
2.78 KB
Binary file not shown.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START routeoptimization_v1_generated_RouteOptimization_OptimizeToursLongRunning_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Maps\RouteOptimization\V1\Client\RouteOptimizationClient;
29+
use Google\Maps\RouteOptimization\V1\OptimizeToursRequest;
30+
use Google\Maps\RouteOptimization\V1\OptimizeToursResponse;
31+
use Google\Rpc\Status;
32+
33+
/**
34+
* This is a variant of the
35+
* [OptimizeTours][google.maps.routeoptimization.v1.RouteOptimization.OptimizeTours]
36+
* method designed for
37+
* optimizations with large timeout values. It should be preferred over the
38+
* `OptimizeTours` method for optimizations that take longer than
39+
* a few minutes.
40+
*
41+
* The returned [long-running operation][google.longrunning.Operation] (LRO)
42+
* will have a name of the format
43+
* `<parent>/operations/<operation_id>` and can be used to track
44+
* progress of the computation. The
45+
* [metadata][google.longrunning.Operation.metadata] field type is
46+
* [OptimizeToursLongRunningMetadata][google.maps.routeoptimization.v1.OptimizeToursLongRunningMetadata].
47+
* The [response][google.longrunning.Operation.response] field type is
48+
* [OptimizeToursResponse][google.maps.routeoptimization.v1.OptimizeToursResponse],
49+
* if successful.
50+
*
51+
* Experimental: See
52+
* https://developers.google.com/maps/tt/route-optimization/experimental/otlr/make-request
53+
* for more details.
54+
*
55+
*
56+
* @param string $parent Target project or location to make a call.
57+
*
58+
* Format:
59+
* * `projects/{project-id}`
60+
* * `projects/{project-id}/locations/{location-id}`
61+
*
62+
* If no location is specified, a region will be chosen automatically.
63+
*/
64+
function optimize_tours_long_running_sample(string $parent): void
65+
{
66+
// Create a client.
67+
$routeOptimizationClient = new RouteOptimizationClient();
68+
69+
// Prepare the request message.
70+
$request = (new OptimizeToursRequest())
71+
->setParent($parent);
72+
73+
// Call the API and handle any network failures.
74+
try {
75+
/** @var OperationResponse $response */
76+
$response = $routeOptimizationClient->optimizeToursLongRunning($request);
77+
$response->pollUntilComplete();
78+
79+
if ($response->operationSucceeded()) {
80+
/** @var OptimizeToursResponse $result */
81+
$result = $response->getResult();
82+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
83+
} else {
84+
/** @var Status $error */
85+
$error = $response->getError();
86+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
87+
}
88+
} catch (ApiException $ex) {
89+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
90+
}
91+
}
92+
93+
/**
94+
* Helper to execute the sample.
95+
*
96+
* This sample has been automatically generated and should be regarded as a code
97+
* template only. It will require modifications to work:
98+
* - It may require correct/in-range values for request initialization.
99+
* - It may require specifying regional endpoints when creating the service client,
100+
* please see the apiEndpoint client configuration option for more details.
101+
*/
102+
function callSample(): void
103+
{
104+
$parent = '[PARENT]';
105+
106+
optimize_tours_long_running_sample($parent);
107+
}
108+
// [END routeoptimization_v1_generated_RouteOptimization_OptimizeToursLongRunning_sync]
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START routeoptimization_v1_generated_RouteOptimization_OptimizeToursUri_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Maps\RouteOptimization\V1\Client\RouteOptimizationClient;
29+
use Google\Maps\RouteOptimization\V1\OptimizeToursUriRequest;
30+
use Google\Maps\RouteOptimization\V1\OptimizeToursUriResponse;
31+
use Google\Maps\RouteOptimization\V1\Uri;
32+
use Google\Rpc\Status;
33+
34+
/**
35+
* This is a variant of the
36+
* [OptimizeToursLongRunning][google.maps.routeoptimization.v1.RouteOptimization.OptimizeToursLongRunning]
37+
* method designed for optimizations with large timeout values and large
38+
* input/output sizes.
39+
*
40+
* The client specifies the URI of the `OptimizeToursRequest` stored
41+
* in Google Cloud Storage and the server writes the `OptimizeToursResponse`
42+
* to a client-specified Google Cloud Storage URI.
43+
*
44+
* This method should be preferred over the `OptimizeTours` method for
45+
* optimizations that take longer than a few minutes and input/output sizes
46+
* that are larger than 8MB, though it can be used for shorter and smaller
47+
* optimizations as well.
48+
*
49+
* The returned [long-running operation][google.longrunning.Operation] (LRO)
50+
* will have a name of the format
51+
* `<parent>/operations/<operation_id>` and can be used to track
52+
* progress of the computation. The
53+
* [metadata][google.longrunning.Operation.metadata] field type is
54+
* [OptimizeToursLongRunningMetadata][google.maps.routeoptimization.v1.OptimizeToursUriMetadata].
55+
* The [response][google.longrunning.Operation.response] field type is
56+
* [OptimizeToursUriResponse][google.maps.routeoptimization.v1.OptimizeToursUriResponse],
57+
* if successful.
58+
*
59+
* Experimental: See
60+
* https://developers.google.com/maps/tt/route-optimization/experimental/otlr/make-request
61+
* for more details.
62+
*
63+
* @param string $parent Target project or location to make a call.
64+
*
65+
* Format:
66+
* * `projects/{project-id}`
67+
* * `projects/{project-id}/locations/{location-id}`
68+
*
69+
* If no location is specified, a region will be chosen automatically.
70+
*/
71+
function optimize_tours_uri_sample(string $parent): void
72+
{
73+
// Create a client.
74+
$routeOptimizationClient = new RouteOptimizationClient();
75+
76+
// Prepare the request message.
77+
$input = new Uri();
78+
$output = new Uri();
79+
$request = (new OptimizeToursUriRequest())
80+
->setParent($parent)
81+
->setInput($input)
82+
->setOutput($output);
83+
84+
// Call the API and handle any network failures.
85+
try {
86+
/** @var OperationResponse $response */
87+
$response = $routeOptimizationClient->optimizeToursUri($request);
88+
$response->pollUntilComplete();
89+
90+
if ($response->operationSucceeded()) {
91+
/** @var OptimizeToursUriResponse $result */
92+
$result = $response->getResult();
93+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
94+
} else {
95+
/** @var Status $error */
96+
$error = $response->getError();
97+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
98+
}
99+
} catch (ApiException $ex) {
100+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
101+
}
102+
}
103+
104+
/**
105+
* Helper to execute the sample.
106+
*
107+
* This sample has been automatically generated and should be regarded as a code
108+
* template only. It will require modifications to work:
109+
* - It may require correct/in-range values for request initialization.
110+
* - It may require specifying regional endpoints when creating the service client,
111+
* please see the apiEndpoint client configuration option for more details.
112+
*/
113+
function callSample(): void
114+
{
115+
$parent = '[PARENT]';
116+
117+
optimize_tours_uri_sample($parent);
118+
}
119+
// [END routeoptimization_v1_generated_RouteOptimization_OptimizeToursUri_sync]

MapsRouteOptimization/src/V1/AggregatedMetrics.php

Lines changed: 104 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)