SnapToRoads
Source:
src/AWS/GeoRoutes/SnapToRoads.ts
Runtime binding for geo-routes:SnapToRoads — match a GPS trace (a list of
possibly-noisy trace points) to the roads most likely traveled on, e.g.
clean up vehicle telemetry before computing distance driven.
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:SnapToRoads. Requests and responses are raw distilled types
(positions are [longitude, latitude] pairs).
Snapping GPS Traces to Roads
Section titled “Snapping GPS Traces to Roads”Provide the SnapToRoadsHttp implementation layer on the Function effect
(.pipe(Effect.provide(AWS.GeoRoutes.SnapToRoadsHttp))), bind in the init
phase, then call the client at runtime.
// initconst snapToRoads = yield* AWS.GeoRoutes.SnapToRoads();
// runtime — positions are [longitude, latitude]const result = yield* snapToRoads({ TracePoints: [ { Position: [-122.339, 47.61] }, { Position: [-122.335, 47.608] }, ], TravelMode: "Car",});const snapped = result.SnappedTracePoints.map((p) => p.SnappedPosition);