Copyright | (c) 2013-2023 Brendan Hay |
---|---|
License | Mozilla Public License, v. 2.0. |
Maintainer | Brendan Hay |
Stability | auto-generated |
Portability | non-portable (GHC extensions) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Calculates a route
given the following required parameters: DeparturePosition
and
DestinationPosition
. Requires that you first
create a route calculator resource.
By default, a request that doesn't specify a departure time uses the best time of day to travel with the best traffic conditions when calculating the route.
Additional options include:
Specifying a departure time using either
DepartureTime
orDepartNow
. This calculates a route based on predictive traffic data at the given time.You can't specify both
DepartureTime
andDepartNow
in a single request. Specifying both parameters returns a validation error.Specifying a travel mode using TravelMode sets the transportation mode used to calculate the routes. This also lets you specify additional route preferences in
CarModeOptions
if traveling byCar
, orTruckModeOptions
if traveling byTruck
.If you specify
walking
for the travel mode and your data provider is Esri, the start and destination must be within 40km.
Synopsis
- data CalculateRoute = CalculateRoute' {
- carModeOptions :: Maybe CalculateRouteCarModeOptions
- departNow :: Maybe Bool
- departureTime :: Maybe ISO8601
- distanceUnit :: Maybe DistanceUnit
- includeLegGeometry :: Maybe Bool
- travelMode :: Maybe TravelMode
- truckModeOptions :: Maybe CalculateRouteTruckModeOptions
- waypointPositions :: Maybe [Sensitive (NonEmpty Double)]
- calculatorName :: Text
- departurePosition :: Sensitive (NonEmpty Double)
- destinationPosition :: Sensitive (NonEmpty Double)
- newCalculateRoute :: Text -> NonEmpty Double -> NonEmpty Double -> CalculateRoute
- calculateRoute_carModeOptions :: Lens' CalculateRoute (Maybe CalculateRouteCarModeOptions)
- calculateRoute_departNow :: Lens' CalculateRoute (Maybe Bool)
- calculateRoute_departureTime :: Lens' CalculateRoute (Maybe UTCTime)
- calculateRoute_distanceUnit :: Lens' CalculateRoute (Maybe DistanceUnit)
- calculateRoute_includeLegGeometry :: Lens' CalculateRoute (Maybe Bool)
- calculateRoute_travelMode :: Lens' CalculateRoute (Maybe TravelMode)
- calculateRoute_truckModeOptions :: Lens' CalculateRoute (Maybe CalculateRouteTruckModeOptions)
- calculateRoute_waypointPositions :: Lens' CalculateRoute (Maybe [NonEmpty Double])
- calculateRoute_calculatorName :: Lens' CalculateRoute Text
- calculateRoute_departurePosition :: Lens' CalculateRoute (NonEmpty Double)
- calculateRoute_destinationPosition :: Lens' CalculateRoute (NonEmpty Double)
- data CalculateRouteResponse = CalculateRouteResponse' {
- httpStatus :: Int
- legs :: [Leg]
- summary :: CalculateRouteSummary
- newCalculateRouteResponse :: Int -> CalculateRouteSummary -> CalculateRouteResponse
- calculateRouteResponse_httpStatus :: Lens' CalculateRouteResponse Int
- calculateRouteResponse_legs :: Lens' CalculateRouteResponse [Leg]
- calculateRouteResponse_summary :: Lens' CalculateRouteResponse CalculateRouteSummary
Creating a Request
data CalculateRoute Source #
See: newCalculateRoute
smart constructor.
CalculateRoute' | |
|
Instances
Create a value of CalculateRoute
with all optional fields omitted.
Use generic-lens or optics to modify other optional fields.
The following record fields are available, with the corresponding lenses provided for backwards compatibility:
$sel:carModeOptions:CalculateRoute'
, calculateRoute_carModeOptions
- Specifies route preferences when traveling by Car
, such as avoiding
routes that use ferries or tolls.
Requirements: TravelMode
must be specified as Car
.
$sel:departNow:CalculateRoute'
, calculateRoute_departNow
- Sets the time of departure as the current time. Uses the current time to
calculate a route. Otherwise, the best time of day to travel with the
best traffic conditions is used to calculate the route.
Default Value: false
Valid Values: false
| true
$sel:departureTime:CalculateRoute'
, calculateRoute_departureTime
- Specifies the desired time of departure. Uses the given time to
calculate the route. Otherwise, the best time of day to travel with the
best traffic conditions is used to calculate the route.
Setting a departure time in the past returns a 400 ValidationException
error.
- In ISO 8601
format:
YYYY-MM-DDThh:mm:ss.sssZ
. For example,2020–07-2T12:15:20.000Z+01:00
CalculateRoute
, calculateRoute_distanceUnit
- Set the unit system to specify the distance.
Default Value: Kilometers
$sel:includeLegGeometry:CalculateRoute'
, calculateRoute_includeLegGeometry
- Set to include the geometry details in the result for each path between
a pair of positions.
Default Value: false
Valid Values: false
| true
$sel:travelMode:CalculateRoute'
, calculateRoute_travelMode
- Specifies the mode of transport when calculating a route. Used in
estimating the speed of travel and road compatibility. You can choose
Car
, Truck
, or Walking
as options for the TravelMode
.
The TravelMode
you specify also determines how you specify route
preferences:
- If traveling by
Car
use theCarModeOptions
parameter. - If traveling by
Truck
use theTruckModeOptions
parameter.
Default Value: Car
$sel:truckModeOptions:CalculateRoute'
, calculateRoute_truckModeOptions
- Specifies route preferences when traveling by Truck
, such as avoiding
routes that use ferries or tolls, and truck specifications to consider
when choosing an optimal road.
Requirements: TravelMode
must be specified as Truck
.
$sel:waypointPositions:CalculateRoute'
, calculateRoute_waypointPositions
- Specifies an ordered list of up to 23 intermediate positions to include
along a route between the departure position and destination position.
- For example, from the
DeparturePosition
[-123.115, 49.285]
, the route follows the order that the waypoint positions are given[[-122.757, 49.0021],[-122.349, 47.620]]
If you specify a waypoint position that's not located on a road, Amazon Location moves the position to the nearest road.
Specifying more than 23 waypoints returns a 400 ValidationException
error.
If Esri is the provider for your route calculator, specifying a route
that is longer than 400 km returns a 400 RoutesValidationException
error.
Valid Values: [-180 to 180,-90 to 90]
CalculateRoute
, calculateRoute_calculatorName
- The name of the route calculator resource that you want to use to
calculate the route.
$sel:departurePosition:CalculateRoute'
, calculateRoute_departurePosition
- The start position for the route. Defined in
World Geodetic System (WGS 84)
format: [longitude, latitude]
.
- For example,
[-123.115, 49.285]
If you specify a departure that's not located on a road, Amazon
Location
moves the position to the nearest road.
If Esri is the provider for your route calculator, specifying a route
that is longer than 400 km returns a 400 RoutesValidationException
error.
Valid Values: [-180 to 180,-90 to 90]
$sel:destinationPosition:CalculateRoute'
, calculateRoute_destinationPosition
- The finish position for the route. Defined in
World Geodetic System (WGS 84)
format: [longitude, latitude]
.
- For example,
[-122.339, 47.615]
If you specify a destination that's not located on a road, Amazon Location moves the position to the nearest road.
Valid Values: [-180 to 180,-90 to 90]
Request Lenses
calculateRoute_carModeOptions :: Lens' CalculateRoute (Maybe CalculateRouteCarModeOptions) Source #
Specifies route preferences when traveling by Car
, such as avoiding
routes that use ferries or tolls.
Requirements: TravelMode
must be specified as Car
.
calculateRoute_departNow :: Lens' CalculateRoute (Maybe Bool) Source #
Sets the time of departure as the current time. Uses the current time to calculate a route. Otherwise, the best time of day to travel with the best traffic conditions is used to calculate the route.
Default Value: false
Valid Values: false
| true
calculateRoute_departureTime :: Lens' CalculateRoute (Maybe UTCTime) Source #
Specifies the desired time of departure. Uses the given time to calculate the route. Otherwise, the best time of day to travel with the best traffic conditions is used to calculate the route.
Setting a departure time in the past returns a 400 ValidationException
error.
- In ISO 8601
format:
YYYY-MM-DDThh:mm:ss.sssZ
. For example,2020–07-2T12:15:20.000Z+01:00
calculateRoute_distanceUnit :: Lens' CalculateRoute (Maybe DistanceUnit) Source #
Set the unit system to specify the distance.
Default Value: Kilometers
calculateRoute_includeLegGeometry :: Lens' CalculateRoute (Maybe Bool) Source #
Set to include the geometry details in the result for each path between a pair of positions.
Default Value: false
Valid Values: false
| true
calculateRoute_travelMode :: Lens' CalculateRoute (Maybe TravelMode) Source #
Specifies the mode of transport when calculating a route. Used in
estimating the speed of travel and road compatibility. You can choose
Car
, Truck
, or Walking
as options for the TravelMode
.
The TravelMode
you specify also determines how you specify route
preferences:
- If traveling by
Car
use theCarModeOptions
parameter. - If traveling by
Truck
use theTruckModeOptions
parameter.
Default Value: Car
calculateRoute_truckModeOptions :: Lens' CalculateRoute (Maybe CalculateRouteTruckModeOptions) Source #
Specifies route preferences when traveling by Truck
, such as avoiding
routes that use ferries or tolls, and truck specifications to consider
when choosing an optimal road.
Requirements: TravelMode
must be specified as Truck
.
calculateRoute_waypointPositions :: Lens' CalculateRoute (Maybe [NonEmpty Double]) Source #
Specifies an ordered list of up to 23 intermediate positions to include along a route between the departure position and destination position.
- For example, from the
DeparturePosition
[-123.115, 49.285]
, the route follows the order that the waypoint positions are given[[-122.757, 49.0021],[-122.349, 47.620]]
If you specify a waypoint position that's not located on a road, Amazon Location moves the position to the nearest road.
Specifying more than 23 waypoints returns a 400 ValidationException
error.
If Esri is the provider for your route calculator, specifying a route
that is longer than 400 km returns a 400 RoutesValidationException
error.
Valid Values: [-180 to 180,-90 to 90]
calculateRoute_calculatorName :: Lens' CalculateRoute Text Source #
The name of the route calculator resource that you want to use to calculate the route.
calculateRoute_departurePosition :: Lens' CalculateRoute (NonEmpty Double) Source #
The start position for the route. Defined in
World Geodetic System (WGS 84)
format: [longitude, latitude]
.
- For example,
[-123.115, 49.285]
If you specify a departure that's not located on a road, Amazon
Location
moves the position to the nearest road.
If Esri is the provider for your route calculator, specifying a route
that is longer than 400 km returns a 400 RoutesValidationException
error.
Valid Values: [-180 to 180,-90 to 90]
calculateRoute_destinationPosition :: Lens' CalculateRoute (NonEmpty Double) Source #
The finish position for the route. Defined in
World Geodetic System (WGS 84)
format: [longitude, latitude]
.
- For example,
[-122.339, 47.615]
If you specify a destination that's not located on a road, Amazon Location moves the position to the nearest road.
Valid Values: [-180 to 180,-90 to 90]
Destructuring the Response
data CalculateRouteResponse Source #
Returns the result of the route calculation. Metadata includes legs and route summary.
See: newCalculateRouteResponse
smart constructor.
CalculateRouteResponse' | |
|
Instances
newCalculateRouteResponse Source #
Create a value of CalculateRouteResponse
with all optional fields omitted.
Use generic-lens or optics to modify other optional fields.
The following record fields are available, with the corresponding lenses provided for backwards compatibility:
$sel:httpStatus:CalculateRouteResponse'
, calculateRouteResponse_httpStatus
- The response's http status code.
$sel:legs:CalculateRouteResponse'
, calculateRouteResponse_legs
- Contains details about each path between a pair of positions included
along a route such as: StartPosition
, EndPosition
, Distance
,
DurationSeconds
, Geometry
, and Steps
. The number of legs returned
corresponds to one fewer than the total number of positions in the
request.
For example, a route with a departure position and destination position returns one leg with the positions snapped to a nearby road:
- The
StartPosition
is the departure position. - The
EndPosition
is the destination position.
A route with a waypoint between the departure and destination position returns two legs with the positions snapped to a nearby road:
- Leg 1: The
StartPosition
is the departure position . TheEndPosition
is the waypoint positon. - Leg 2: The
StartPosition
is the waypoint position. TheEndPosition
is the destination position.
$sel:summary:CalculateRouteResponse'
, calculateRouteResponse_summary
- Contains information about the whole route, such as: RouteBBox
,
DataSource
, Distance
, DistanceUnit
, and DurationSeconds
.
Response Lenses
calculateRouteResponse_httpStatus :: Lens' CalculateRouteResponse Int Source #
The response's http status code.
calculateRouteResponse_legs :: Lens' CalculateRouteResponse [Leg] Source #
Contains details about each path between a pair of positions included
along a route such as: StartPosition
, EndPosition
, Distance
,
DurationSeconds
, Geometry
, and Steps
. The number of legs returned
corresponds to one fewer than the total number of positions in the
request.
For example, a route with a departure position and destination position returns one leg with the positions snapped to a nearby road:
- The
StartPosition
is the departure position. - The
EndPosition
is the destination position.
A route with a waypoint between the departure and destination position returns two legs with the positions snapped to a nearby road:
- Leg 1: The
StartPosition
is the departure position . TheEndPosition
is the waypoint positon. - Leg 2: The
StartPosition
is the waypoint position. TheEndPosition
is the destination position.
calculateRouteResponse_summary :: Lens' CalculateRouteResponse CalculateRouteSummary Source #
Contains information about the whole route, such as: RouteBBox
,
DataSource
, Distance
, DistanceUnit
, and DurationSeconds
.