- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
OptimizeWaypointsCommand
Calculates the optimal order to travel between a set of waypoints to minimize either the travel time or the distance travelled during the journey, based on road network restrictions and the traffic pattern data.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { GeoRoutesClient, OptimizeWaypointsCommand } from "@aws-sdk/client-geo-routes"; // ES Modules import
// const { GeoRoutesClient, OptimizeWaypointsCommand } = require("@aws-sdk/client-geo-routes"); // CommonJS import
const client = new GeoRoutesClient(config);
const input = { // OptimizeWaypointsRequest
Avoid: { // WaypointOptimizationAvoidanceOptions
Areas: [ // WaypointOptimizationAvoidanceAreaList
{ // WaypointOptimizationAvoidanceArea
Geometry: { // WaypointOptimizationAvoidanceAreaGeometry
BoundingBox: [ // BoundingBox
Number("double"),
],
},
},
],
CarShuttleTrains: true || false,
ControlledAccessHighways: true || false,
DirtRoads: true || false,
Ferries: true || false,
TollRoads: true || false,
Tunnels: true || false,
UTurns: true || false,
},
DepartureTime: "STRING_VALUE",
Destination: [ // Position
Number("double"),
],
DestinationOptions: { // WaypointOptimizationDestinationOptions
AccessHours: { // WaypointOptimizationAccessHours
From: { // WaypointOptimizationAccessHoursEntry
DayOfWeek: "STRING_VALUE", // required
TimeOfDay: "STRING_VALUE", // required
},
To: {
DayOfWeek: "STRING_VALUE", // required
TimeOfDay: "STRING_VALUE", // required
},
},
AppointmentTime: "STRING_VALUE",
Heading: Number("double"),
Id: "STRING_VALUE",
ServiceDuration: Number("long"),
SideOfStreet: { // WaypointOptimizationSideOfStreetOptions
Position: [ // required
Number("double"),
],
UseWith: "STRING_VALUE",
},
},
Driver: { // WaypointOptimizationDriverOptions
RestCycles: { // WaypointOptimizationRestCycles
LongCycle: { // WaypointOptimizationRestCycleDurations
RestDuration: Number("long"), // required
WorkDuration: Number("long"), // required
},
ShortCycle: {
RestDuration: Number("long"), // required
WorkDuration: Number("long"), // required
},
},
RestProfile: { // WaypointOptimizationRestProfile
Profile: "STRING_VALUE", // required
},
TreatServiceTimeAs: "STRING_VALUE",
},
Exclude: { // WaypointOptimizationExclusionOptions
Countries: [ // CountryCodeList // required
"STRING_VALUE",
],
},
Key: "STRING_VALUE",
OptimizeSequencingFor: "STRING_VALUE",
Origin: [ // required
Number("double"),
],
OriginOptions: { // WaypointOptimizationOriginOptions
Id: "STRING_VALUE",
},
Traffic: { // WaypointOptimizationTrafficOptions
Usage: "STRING_VALUE",
},
TravelMode: "STRING_VALUE",
TravelModeOptions: { // WaypointOptimizationTravelModeOptions
Pedestrian: { // WaypointOptimizationPedestrianOptions
Speed: Number("double"),
},
Truck: { // WaypointOptimizationTruckOptions
GrossWeight: Number("long"),
HazardousCargos: [ // WaypointOptimizationHazardousCargoTypeList
"STRING_VALUE",
],
Height: Number("long"),
Length: Number("long"),
Trailer: { // WaypointOptimizationTrailerOptions
TrailerCount: Number("int"),
},
TruckType: "STRING_VALUE",
TunnelRestrictionCode: "STRING_VALUE",
WeightPerAxle: Number("long"),
Width: Number("long"),
},
},
Waypoints: [ // WaypointOptimizationWaypointList
{ // WaypointOptimizationWaypoint
AccessHours: {
From: {
DayOfWeek: "STRING_VALUE", // required
TimeOfDay: "STRING_VALUE", // required
},
To: {
DayOfWeek: "STRING_VALUE", // required
TimeOfDay: "STRING_VALUE", // required
},
},
AppointmentTime: "STRING_VALUE",
Before: [ // BeforeWaypointsList
Number("int"),
],
Heading: Number("double"),
Id: "STRING_VALUE",
Position: [ // required
Number("double"),
],
ServiceDuration: Number("long"),
SideOfStreet: {
Position: "<Position>", // required
UseWith: "STRING_VALUE",
},
},
],
};
const command = new OptimizeWaypointsCommand(input);
const response = await client.send(command);
// { // OptimizeWaypointsResponse
// Connections: [ // WaypointOptimizationConnectionList // required
// { // WaypointOptimizationConnection
// Distance: Number("long"), // required
// From: "STRING_VALUE", // required
// RestDuration: Number("long"), // required
// To: "STRING_VALUE", // required
// TravelDuration: Number("long"), // required
// WaitDuration: Number("long"), // required
// },
// ],
// Distance: Number("long"), // required
// Duration: Number("long"), // required
// ImpedingWaypoints: [ // WaypointOptimizationImpedingWaypointList // required
// { // WaypointOptimizationImpedingWaypoint
// FailedConstraints: [ // WaypointOptimizationFailedConstraintList // required
// { // WaypointOptimizationFailedConstraint
// Constraint: "STRING_VALUE",
// Reason: "STRING_VALUE",
// },
// ],
// Id: "STRING_VALUE", // required
// Position: [ // Position // required
// Number("double"),
// ],
// },
// ],
// OptimizedWaypoints: [ // WaypointOptimizationOptimizedWaypointList // required
// { // WaypointOptimizationOptimizedWaypoint
// ArrivalTime: "STRING_VALUE",
// DepartureTime: "STRING_VALUE", // required
// Id: "STRING_VALUE", // required
// Position: [ // required
// Number("double"),
// ],
// },
// ],
// PricingBucket: "STRING_VALUE", // required
// TimeBreakdown: { // WaypointOptimizationTimeBreakdown
// RestDuration: Number("long"), // required
// ServiceDuration: Number("long"), // required
// TravelDuration: Number("long"), // required
// WaitDuration: Number("long"), // required
// },
// };
OptimizeWaypointsCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
Origin Required | number[] | undefined | The start position for the route. |
Avoid | WaypointOptimizationAvoidanceOptions | undefined | Features that are avoided while calculating a route. Avoidance is on a best-case basis. If an avoidance can't be satisfied for a particular case, this setting is ignored. |
DepartureTime | string | undefined | Departure time from the waypoint. Time format: Examples: |
Destination | number[] | undefined | The final position for the route in the World Geodetic System (WGS 84) format: |
DestinationOptions | WaypointOptimizationDestinationOptions | undefined | Destination related options. |
Driver | WaypointOptimizationDriverOptions | undefined | Driver related options. |
Exclude | WaypointOptimizationExclusionOptions | undefined | Features to be strictly excluded while calculating the route. |
Key | string | undefined | Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request. |
OptimizeSequencingFor | WaypointOptimizationSequencingObjective | undefined | Specifies the optimization criteria for the calculated sequence. Default Value: |
OriginOptions | WaypointOptimizationOriginOptions | undefined | Origin related options. |
Traffic | WaypointOptimizationTrafficOptions | undefined | Traffic-related options. |
TravelMode | WaypointOptimizationTravelMode | undefined | Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road compatibility. Default Value: |
TravelModeOptions | WaypointOptimizationTravelModeOptions | undefined | Travel mode related options for the provided travel mode. |
Waypoints | WaypointOptimizationWaypoint[] | undefined | List of waypoints between the |
OptimizeWaypointsCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Connections Required | WaypointOptimizationConnection[] | undefined | Details about the connection from one waypoint to the next, within the optimized sequence. |
Distance Required | number | undefined | Overall distance to travel the whole sequence. |
Duration Required | number | undefined | Overall duration to travel the whole sequence. Unit: |
ImpedingWaypoints Required | WaypointOptimizationImpedingWaypoint[] | undefined | Returns waypoints that caused the optimization problem to fail, and the constraints that were unsatisfied leading to the failure. |
OptimizedWaypoints Required | WaypointOptimizationOptimizedWaypoint[] | undefined | Waypoints in the order of the optimized sequence. |
PricingBucket Required | string | undefined | The pricing bucket for which the query is charged at. |
TimeBreakdown Required | WaypointOptimizationTimeBreakdown | undefined | Time breakdown for the sequence. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
AccessDeniedException | client | You don't have sufficient access to perform this action. |
InternalServerException | server | The request processing has failed because of an unknown error, exception or failure. |
ThrottlingException | client | The request was denied due to request throttling. |
ValidationException | client | The input fails to satisfy the constraints specified by an AWS service. |
GeoRoutesServiceException | Base exception class for all service exceptions from GeoRoutes service. |