Skip to content

CalculateRoutes

Source: src/AWS/GeoRoutes/CalculateRoutes.ts

Runtime binding for geo-routes:CalculateRoutes — compute one or more routes between an origin and a destination, with optional waypoints, travel mode, and traffic options.

geo-routes is a standalone, pay-per-call Amazon Location API with no resource to manage: the binding takes no arguments and grants the function geo-routes:CalculateRoutes. Requests and responses are raw distilled types (Origin/Destination are [longitude, latitude] pairs).

Provide the CalculateRoutesHttp implementation layer on the Function effect (.pipe(Effect.provide(AWS.GeoRoutes.CalculateRoutesHttp))), bind in the init phase, then call the client at runtime.

// init
const calculateRoutes = yield* AWS.GeoRoutes.CalculateRoutes();
// runtime — coordinates are [longitude, latitude]
const result = yield* calculateRoutes({
Origin: [-122.339, 47.61],
Destination: [-122.201, 47.61],
TravelMode: "Car",
});
const distanceMeters = result.Routes?.[0]?.Summary?.Distance;