ExAws.Location.Routes (ex_aws_location v0.1.0)

Copy Markdown

API calls for Amazon Location Service Routes (the geo-routes API).

Route calculation, route matrices, isolines, waypoint optimisation and snap-to-roads.

Every function returns an operation struct to be passed to ExAws.request/2.

Operations

  • calculate_isolines - CalculateIsolines
  • calculate_route_matrix - CalculateRouteMatrix
  • calculate_routes - CalculateRoutes
  • optimize_waypoints - OptimizeWaypoints
  • snap_to_roads - SnapToRoads

See https://docs.aws.amazon.com/location/latest/APIReference/API_Operations_Amazon_Location_Service_Routes_V2.html

Summary

Functions

Calculates areas that can be reached within specified time or distance thresholds from a given point. For example, you can use this operation to determine the area within a 30-minute drive of a store location, find neighborhoods within walking distance of a school, or identify delivery zones based on drive time.

Use CalculateRouteMatrix to compute results for all pairs of Origins to Destinations. Each row corresponds to one entry in Origins. Each entry in the row corresponds to the route from that entry in Origins to an entry in Destinations positions.

CalculateRoutes computes routes given the following required parameters: Origin and Destination.

OptimizeWaypoints 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.

SnapToRoads matches GPS trace to roads most likely traveled on.

Types

calculate_isolines_opts()

@type calculate_isolines_opts() :: [
  allow: ExAws.Location.Routes.IsolineAllowOptions.t(),
  arrival_time: String.t(),
  avoid: ExAws.Location.Routes.IsolineAvoidanceOptions.t(),
  depart_now: boolean(),
  departure_time: String.t(),
  destination: [number()],
  destination_options: ExAws.Location.Routes.IsolineDestinationOptions.t(),
  isoline_geometry_format: String.t(),
  isoline_granularity: ExAws.Location.Routes.IsolineGranularityOptions.t(),
  key: String.t(),
  optimize_isoline_for: String.t(),
  optimize_routing_for: String.t(),
  origin: [number()],
  origin_options: ExAws.Location.Routes.IsolineOriginOptions.t(),
  traffic: ExAws.Location.Routes.IsolineTrafficOptions.t(),
  travel_mode: String.t(),
  travel_mode_options: ExAws.Location.Routes.IsolineTravelModeOptions.t()
]

calculate_route_matrix_opts()

@type calculate_route_matrix_opts() :: [
  allow: ExAws.Location.Routes.RouteMatrixAllowOptions.t(),
  avoid: ExAws.Location.Routes.RouteMatrixAvoidanceOptions.t(),
  depart_now: boolean(),
  departure_time: String.t(),
  exclude: ExAws.Location.Routes.RouteMatrixExclusionOptions.t(),
  key: String.t(),
  optimize_routing_for: String.t(),
  routing_boundary: ExAws.Location.Routes.RouteMatrixBoundary.t(),
  traffic: ExAws.Location.Routes.RouteMatrixTrafficOptions.t(),
  travel_mode: String.t(),
  travel_mode_options: ExAws.Location.Routes.RouteMatrixTravelModeOptions.t()
]

calculate_routes_opts()

@type calculate_routes_opts() :: [
  allow: ExAws.Location.Routes.RouteAllowOptions.t(),
  arrival_time: String.t(),
  avoid: ExAws.Location.Routes.RouteAvoidanceOptions.t(),
  depart_now: boolean(),
  departure_time: String.t(),
  destination_options: ExAws.Location.Routes.RouteDestinationOptions.t(),
  driver: ExAws.Location.Routes.RouteDriverOptions.t(),
  exclude: ExAws.Location.Routes.RouteExclusionOptions.t(),
  instructions_measurement_system: String.t(),
  key: String.t(),
  languages: [String.t()],
  leg_additional_features: [String.t()],
  leg_geometry_format: String.t(),
  max_alternatives: integer(),
  optimize_routing_for: String.t(),
  origin_options: ExAws.Location.Routes.RouteOriginOptions.t(),
  span_additional_features: [String.t()],
  tolls: ExAws.Location.Routes.RouteTollOptions.t(),
  traffic: ExAws.Location.Routes.RouteTrafficOptions.t(),
  travel_mode: String.t(),
  travel_mode_options: ExAws.Location.Routes.RouteTravelModeOptions.t(),
  travel_step_type: String.t(),
  waypoints: [ExAws.Location.Routes.RouteWaypoint.t()]
]

optimize_waypoints_opts()

snap_to_roads_opts()

@type snap_to_roads_opts() :: [
  key: String.t(),
  snap_radius: integer(),
  snapped_geometry_format: String.t(),
  travel_mode: String.t(),
  travel_mode_options: ExAws.Location.Routes.RoadSnapTravelModeOptions.t()
]

Functions

calculate_isolines(thresholds, opts \\ [])

Calculates areas that can be reached within specified time or distance thresholds from a given point. For example, you can use this operation to determine the area within a 30-minute drive of a store location, find neighborhoods within walking distance of a school, or identify delivery zones based on drive time.

Isolines (also known as isochrones for time-based calculations) are useful for various applications including:

  • Service area visualization - Show customers the area you can serve within promised delivery times

  • Site selection - Analyze potential business locations based on population within travel distance

  • Site selection - Determine areas that can be reached within specified response times

Route preferences such as avoiding toll roads or ferries are treated as preferences rather than absolute restrictions. If a viable route cannot be calculated while honoring all preferences, some may be ignored.

For more information, see Calculate isolines in the Amazon Location Service Developer Guide.

Parameters

  • thresholds - The distance or time thresholds used to determine reachable areas. You can specify up to five thresholds (which all must be the same type) to calculate multiple isolines in a single request. For example, to determine the areas that are reachable within 10 and 20 minutes of the origin, specify time thresholds of 600 and 1200 seconds.

Options

  • :allow - Enables special road types or features that should be considered for routing even if they might be restricted by default for the selected travel mode. These include high-occupancy vehicle and toll lanes.

  • :arrival_time - Determine areas from which Destination can be reached by this time, taking into account predicted traffic conditions and working backward to account for congestion patterns. This attribute cannot be used together with DepartureTime or DepartNow. Specified as an ISO-8601 timestamp with timezone offset.

  • :avoid - Specifies road types, features, or areas to avoid (if possible) when calculating reachable areas. These are treated as preferences rather than strict constraints—if a route cannot be calculated without using an avoided feature, that avoidance preference may be ignored.

  • :depart_now - When true, uses the current time as the departure time and takes current traffic conditions into account. This attribute cannot be used together with DepartureTime or ArrivalTime.

  • :departure_time - Determine areas that can be reached when departing at this time, taking into account predicted traffic conditions. This attribute cannot be used together with ArrivalTime or DepartNow. Specified as an ISO-8601 timestamp with timezone offset.

  • :destination - An optional destination point, specified as [longitude, latitude] coordinates. When provided, the service calculates areas from which this destination can be reached within the specified thresholds. This reverses the usual isoline calculation to show areas that could reach your location, rather than areas you could reach from your location. Either Origin or Destination must be provided.

  • :destination_options - Options that control how the destination point is matched to the road network and how routes can approach it. These options help improve travel time accuracy by accounting for real-world access to the destination.

  • :isoline_geometry_format - The format of the returned IsolineGeometry. Valid values: FlexiblePolyline, Simple.

  • :isoline_granularity - Controls the detail level of the generated isolines. Higher granularity produces smoother shapes but requires more processing time and results in larger responses.

  • :key - An Amazon Location Service API Key with access to this action. If omitted, the request must be signed using Signature Version 4.

  • :optimize_isoline_for - Controls the trade-off between calculation speed and isoline precision. Choose FastCalculation for quicker results with less detail, AccurateCalculation for more precise results, or BalancedCalculation for a middle ground. Valid values: AccurateCalculation, BalancedCalculation, FastCalculation.

  • :optimize_routing_for - Determines whether routes prioritize shortest travel time (FastestRoute) or shortest physical distance (ShortestRoute) when calculating reachable areas. Valid values: FastestRoute, ShortestRoute.

  • :origin - The starting point for isoline calculations, specified as [longitude, latitude] coordinates. For example, this could be a store location, service center, or any point from which you want to calculate reachable areas. Either Origin or Destination must be provided.

  • :origin_options - Options that control how the origin point is matched to the road network and how routes can depart from it. These options help improve travel time accuracy by accounting for real-world access from the origin.

  • :traffic - Configures how real-time and historical traffic data affects isoline calculations. Traffic patterns can significantly impact reachable areas, especially during peak hours.

  • :travel_mode - The mode of transportation to use for calculations. This affects which road types or features can be used, estimated speed, and the traffic levels that are applied. Valid values: Car, Pedestrian, Scooter, Truck.

  • :travel_mode_options - Additional attributes that refine how reachable areas are calculated based on specific vehicle characteristics. These options help produce more accurate results by accounting for real-world constraints and capabilities.

See https://docs.aws.amazon.com/location/latest/APIReference/API_CalculateIsolines.html

calculate_route_matrix(destinations, origins, opts \\ [])

Use CalculateRouteMatrix to compute results for all pairs of Origins to Destinations. Each row corresponds to one entry in Origins. Each entry in the row corresponds to the route from that entry in Origins to an entry in Destinations positions.

For more information, see Calculate route matrix in the Amazon Location Service Developer Guide.

Parameters

  • destinations - List of destinations for the route in World Geodetic System (WGS 84) format: [longitude, latitude].

  • origins - List of origins for the route in World Geodetic System (WGS 84) format: [longitude, latitude].

Options

  • :allow - Features that are allowed while calculating a route.

  • :avoid - 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, it violates the avoidance and the returned response produces a notice for the violation. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only TollRoads, Ferries, and ControlledAccessHighways.

  • :depart_now - Uses the current time as the time of departure.

  • :departure_time - Time of departure from the origin.

  • :exclude - Features to be strictly excluded while calculating the route. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :key - Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

  • :optimize_routing_for - Controls the trade-off between finding the shortest travel time (FastestRoute) and the shortest distance (ShortestRoute) when calculating reachable areas. Valid values: FastestRoute, ShortestRoute.

  • :routing_boundary - Boundary within which the matrix is to be calculated. All data, origins and destinations outside the boundary are considered invalid. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only Unbounded set to true.

  • :traffic - Traffic related options. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :travel_mode - Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road compatibility. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only Car, Pedestrian, and Scooter. Valid values: Car, Pedestrian, Scooter, Truck.

  • :travel_mode_options - Travel mode related options for the provided travel mode. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

See https://docs.aws.amazon.com/location/latest/APIReference/API_CalculateRouteMatrix.html

calculate_routes(destination, origin, opts \\ [])

@spec calculate_routes([number()], [number()], calculate_routes_opts()) ::
  ExAws.Operation.JSON.t()

CalculateRoutes computes routes given the following required parameters: Origin and Destination.

For more information, see Calculate routes in the Amazon Location Service Developer Guide.

Parameters

  • destination - The final position for the route. In the World Geodetic System (WGS 84) format: [longitude, latitude].

  • origin - The start position for the route in World Geodetic System (WGS 84) format: [longitude, latitude].

Options

  • :allow - Features that are allowed while calculating a route. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :arrival_time - Time of arrival at the destination. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :avoid - 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, it violates the avoidance and the returned response produces a notice for the violation. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only ControlledAccessHighways, Ferries, and TollRoads

  • :depart_now - Uses the current time as the time of departure.

  • :departure_time - Time of departure from the origin.

  • :destination_options - Destination related options. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :driver - Driver related options. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :exclude - Features to be strictly excluded while calculating the route. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :instructions_measurement_system - Measurement system to be used for instructions within steps in the response. Valid values: Metric, Imperial.

  • :key - Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

  • :languages - List of languages for instructions within steps in the response. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :leg_additional_features - A list of optional additional parameters such as timezone that can be requested for each result. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only PassThroughWaypoints, Summary, and TravelStepInstructions Valid values: Elevation, Incidents, PassThroughWaypoints, Summary, Tolls, TravelStepInstructions, TruckRoadTypes, TypicalDuration, Zones, Bookings, IntermediateStops, NextDepartures.

  • :leg_geometry_format - Specifies the format of the geometry returned for each leg of the route. You can choose between two different geometry encoding formats. Valid values: FlexiblePolyline, Simple.

  • :max_alternatives - Maximum number of alternative routes to be provided in the response, if available. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only up to 3 alternative routes.

  • :optimize_routing_for - Controls the trade-off between achieving the shortest travel time (FastestRoute) and achieving the shortest physical distance ((ShortestRoute) when calculating each route in the matrix. Valid values: FastestRoute, ShortestRoute.

  • :origin_options - Specifies how the origin point should be matched to the road network and any routing constraints that apply when the traveler is departing the origin. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :span_additional_features - A list of optional features such as SpeedLimit that can be requested for a Span. A span is a section of a Leg for which the requested features have the same values. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers. Valid values: BestCaseDuration, CarAccess, Country, Distance, Duration, DynamicSpeed, FunctionalClassification, Gates, Incidents, Names, Notices, PedestrianAccess, RailwayCrossings, Region, RoadAttributes, RouteNumbers, ScooterAccess, SpeedLimit, TollSystems, TruckAccess, TruckRoadTypes, TypicalDuration, Zones, Consumption.

  • :tolls - Toll related options. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :traffic - Traffic related options. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • :travel_mode - Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road compatibility. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only Car, Pedestrian, and Scooter values. Valid values: Car, Pedestrian, Scooter, Truck, Intermodal, Transit.

  • :travel_mode_options - Travel mode related options for the provided travel mode. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only Car and Pedestrian travel mode options.

  • :travel_step_type - Type of step returned by the response. Default provides basic steps intended for web based applications. TurnByTurn provides detailed instructions with more granularity intended for a turn based navigation system. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions Default does not return any steps. Valid values: Default, TurnByTurn.

  • :waypoints - List of waypoints between the Origin and Destination. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions max length is 100.

See https://docs.aws.amazon.com/location/latest/APIReference/API_CalculateRoutes.html

optimize_waypoints(origin, opts \\ [])

@spec optimize_waypoints([number()], optimize_waypoints_opts()) ::
  ExAws.Operation.JSON.t()

OptimizeWaypoints 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.

For more information, see Optimize waypoints in the Amazon Location Service Developer Guide.

Parameters

  • origin - The start position for the route in World Geodetic System (WGS 84) format: [longitude, latitude].

Options

  • :avoid - Features that are avoided. Avoidance is on a best-case basis. If an avoidance can't be satisfied for a particular case, this setting is ignored.

  • :clustering - Clustering allows you to specify how nearby waypoints can be clustered to improve the optimized sequence.

  • :departure_time - Departure time from the waypoint.

  • :destination - The final position for the route in the World Geodetic System (WGS 84) format: [longitude, latitude].

  • :destination_options - Destination related options.

  • :driver - Driver related options.

  • :exclude - Features to be strictly excluded while calculating the route.

  • :key - Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

  • :optimize_sequencing_for - Specifies the optimization criteria for the calculated sequence. Valid values: FastestRoute, ShortestRoute.

  • :origin_options - Origin related options.

  • :traffic - Traffic-related options.

  • :travel_mode - Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road compatibility. Valid values: Car, Pedestrian, Scooter, Truck.

  • :travel_mode_options - Travel mode related options for the provided travel mode.

  • :waypoints - List of waypoints between the Origin and Destination, in World Geodetic System (WGS 84) format: [longitude, latitude].

See https://docs.aws.amazon.com/location/latest/APIReference/API_OptimizeWaypoints.html

snap_to_roads(trace_points, opts \\ [])

SnapToRoads matches GPS trace to roads most likely traveled on.

For more information, see Snap to Roads in the Amazon Location Service Developer Guide.

Parameters

  • trace_points - List of trace points to be snapped onto the road network.

Options

  • :key - Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

  • :snap_radius - The radius around the provided tracepoint that is considered for snapping.

  • :snapped_geometry_format - Chooses what the returned SnappedGeometry format should be. Valid values: FlexiblePolyline, Simple.

  • :travel_mode - Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road compatibility. Valid values: Car, Pedestrian, Scooter, Truck.

  • :travel_mode_options - Travel mode related options for the provided travel mode.

See https://docs.aws.amazon.com/location/latest/APIReference/API_SnapToRoads.html