1import type * as geoRoutes from "@distilled.cloud/aws/geo-routes";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4
5/**
6 * Runtime binding for `geo-routes:CalculateRouteMatrix` — compute travel time
7 * and distance for all pairs of origins to destinations in one call (an
8 * origin-destination cost matrix), e.g. rank the nearest store for each
9 * customer.
10 *
11 * geo-routes is a standalone, pay-per-call Amazon Location API with no
12 * resource to manage: the binding takes no arguments and grants the function
13 * `geo-routes:CalculateRouteMatrix`. Requests and responses are raw distilled
14 * types (positions are `[longitude, latitude]` pairs). The matrix requires a
15 * `RoutingBoundary` — a geometry that contains all origins and destinations,
16 * or `{ Unbounded: true }`.
17 *
18 * ### Calculating a Route Matrix
19 * Provide the `CalculateRouteMatrixHttp` implementation layer on the Function
20 * effect (`.pipe(Effect.provide(AWS.GeoRoutes.CalculateRouteMatrixHttp))`),
21 * bind in the init phase, then call the client at runtime.
22 *
23 * **Example:** Calculate a 2x2 origin-destination matrix
24 * ```typescript
25 * // init
26 * const calculateRouteMatrix = yield* AWS.GeoRoutes.CalculateRouteMatrix();
27 *
28 * // runtime — positions are [longitude, latitude]
29 * const result = yield* calculateRouteMatrix({
30 * Origins: [
31 * { Position: [-122.339, 47.61] },
32 * { Position: [-122.335, 47.608] },
33 * ],
34 * Destinations: [
35 * { Position: [-122.201, 47.61] },
36 * { Position: [-122.313, 47.62] },
37 * ],
38 * RoutingBoundary: {
39 * Geometry: { Circle: { Center: [-122.3, 47.61], Radius: 30_000 } },
40 * },
41 * });
42 * const secondsFromFirstOriginToFirstDestination =
43 * result.RouteMatrix[0]?.[0]?.Duration;
44 * ```
45 *
46 * @binding
47 */
48export interface CalculateRouteMatrix extends Binding.Service<
49 CalculateRouteMatrix,
50 "AWS.GeoRoutes.CalculateRouteMatrix",
51 () => Effect.Effect<
52 (
53 request: geoRoutes.CalculateRouteMatrixRequest,
54 ) => Effect.Effect<
55 geoRoutes.CalculateRouteMatrixResponse,
56 geoRoutes.CalculateRouteMatrixError
57 >
58 >
59> {}
60export const CalculateRouteMatrix = Binding.Service<CalculateRouteMatrix>(
61 "AWS.GeoRoutes.CalculateRouteMatrix",
62);