snapToRoads method
SnapToRoads matches GPS trace to roads most likely traveled
on.
For more information, see Snap to Roads in the Amazon Location Service Developer Guide.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ThrottlingException.
May throw ValidationException.
Parameter tracePoints :
List of trace points to be snapped onto the road network.
Parameter 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.
Parameter snapRadius :
The radius around the provided tracepoint that is considered for snapping.
Unit: meters
Default value: 300
Parameter snappedGeometryFormat :
Chooses what the returned SnappedGeometry format should be.
Default value: FlexiblePolyline
Parameter travelMode :
Specifies the mode of transport when calculating a route. Used in
estimating the speed of travel and road compatibility.
Default value: Car
Parameter travelModeOptions :
Travel mode related options for the provided travel mode.
Implementation
Future<SnapToRoadsResponse> snapToRoads({
required List<RoadSnapTracePoint> tracePoints,
String? key,
int? snapRadius,
GeometryFormat? snappedGeometryFormat,
RoadSnapTravelMode? travelMode,
RoadSnapTravelModeOptions? travelModeOptions,
}) async {
_s.validateNumRange(
'snapRadius',
snapRadius,
0,
4294967295,
);
final $query = <String, List<String>>{
if (key != null) 'key': [key],
};
final $payload = <String, dynamic>{
'TracePoints': tracePoints,
if (snapRadius != null) 'SnapRadius': snapRadius,
if (snappedGeometryFormat != null)
'SnappedGeometryFormat': snappedGeometryFormat.value,
if (travelMode != null) 'TravelMode': travelMode.value,
if (travelModeOptions != null) 'TravelModeOptions': travelModeOptions,
};
final response = await _protocol.sendRaw(
payload: $payload,
method: 'POST',
requestUri: '/v2/snap-to-roads',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
final $json = await _s.jsonFromResponse(response);
return SnapToRoadsResponse(
notices: (($json['Notices'] as List?) ?? const [])
.nonNulls
.map((e) => RoadSnapNotice.fromJson(e as Map<String, dynamic>))
.toList(),
snappedGeometryFormat: GeometryFormat.fromString(
($json['SnappedGeometryFormat'] as String?) ?? ''),
snappedTracePoints: (($json['SnappedTracePoints'] as List?) ?? const [])
.nonNulls
.map((e) =>
RoadSnapSnappedTracePoint.fromJson(e as Map<String, dynamic>))
.toList(),
snappedGeometry: $json['SnappedGeometry'] != null
? RoadSnapSnappedGeometry.fromJson(
$json['SnappedGeometry'] as Map<String, dynamic>)
: null,
pricingBucket: _s.extractHeaderStringValue(
response.headers, 'x-amz-geo-pricing-bucket')!,
);
}