| 1 | import type * as geoRoutes from "@distilled.cloud/aws/geo-routes"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | |
| 5 | /** |
| 6 | * Runtime binding for `geo-routes:SnapToRoads` — match a GPS trace (a list of |
| 7 | * possibly-noisy trace points) to the roads most likely traveled on, e.g. |
| 8 | * clean up vehicle telemetry before computing distance driven. |
| 9 | * |
| 10 | * geo-routes is a standalone, pay-per-call Amazon Location API with no |
| 11 | * resource to manage: the binding takes no arguments and grants the function |
| 12 | * `geo-routes:SnapToRoads`. Requests and responses are raw distilled types |
| 13 | * (positions are `[longitude, latitude]` pairs). |
| 14 | * |
| 15 | * ### Snapping GPS Traces to Roads |
| 16 | * Provide the `SnapToRoadsHttp` implementation layer on the Function effect |
| 17 | * (`.pipe(Effect.provide(AWS.GeoRoutes.SnapToRoadsHttp))`), bind in the init |
| 18 | * phase, then call the client at runtime. |
| 19 | * |
| 20 | * **Example:** Snap a two-point GPS trace to the road network |
| 21 | * ```typescript |
| 22 | * // init |
| 23 | * const snapToRoads = yield* AWS.GeoRoutes.SnapToRoads(); |
| 24 | * |
| 25 | * // runtime — positions are [longitude, latitude] |
| 26 | * const result = yield* snapToRoads({ |
| 27 | * TracePoints: [ |
| 28 | * { Position: [-122.339, 47.61] }, |
| 29 | * { Position: [-122.335, 47.608] }, |
| 30 | * ], |
| 31 | * TravelMode: "Car", |
| 32 | * }); |
| 33 | * const snapped = result.SnappedTracePoints.map((p) => p.SnappedPosition); |
| 34 | * ``` |
| 35 | * |
| 36 | * @binding |
| 37 | */ |
| 38 | export interface SnapToRoads extends Binding.Service< |
| 39 | SnapToRoads, |
| 40 | "AWS.GeoRoutes.SnapToRoads", |
| 41 | () => Effect.Effect< |
| 42 | ( |
| 43 | request: geoRoutes.SnapToRoadsRequest, |
| 44 | ) => Effect.Effect< |
| 45 | geoRoutes.SnapToRoadsResponse, |
| 46 | geoRoutes.SnapToRoadsError |
| 47 | > |
| 48 | > |
| 49 | > {} |
| 50 | export const SnapToRoads = Binding.Service<SnapToRoads>( |
| 51 | "AWS.GeoRoutes.SnapToRoads", |
| 52 | ); |