forecastGeofenceEvents method

Future<ForecastGeofenceEventsResponse> forecastGeofenceEvents({
  1. required String collectionName,
  2. required ForecastGeofenceEventsDeviceState deviceState,
  3. DistanceUnit? distanceUnit,
  4. int? maxResults,
  5. String? nextToken,
  6. SpeedUnit? speedUnit,
  7. double? timeHorizonMinutes,
})

This action forecasts future geofence events that are likely to occur within a specified time horizon if a device continues moving at its current speed. Each forecasted event is associated with a geofence from a provided geofence collection. A forecast event can have one of the following states:

ENTER: The device position is outside the referenced geofence, but the device may cross into the geofence during the forecasting time horizon if it maintains its current speed.

EXIT: The device position is inside the referenced geofence, but the device may leave the geofence during the forecasted time horizon if the device maintains it's current speed.

IDLE:The device is inside the geofence, and it will remain inside the geofence through the end of the time horizon if the device maintains it's current speed.

May throw AccessDeniedException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter collectionName : The name of the geofence collection.

Parameter deviceState : Represents the device's state, including its current position and speed. When speed is omitted, this API performs a containment check. The containment check operation returns IDLE events for geofences where the device is currently inside of, but no other events.

Parameter distanceUnit : The distance unit used for the NearestDistance property returned in a forecasted event. The measurement system must match for DistanceUnit and SpeedUnit; if Kilometers is specified for DistanceUnit, then SpeedUnit must be KilometersPerHour.

Default Value: Kilometers

Parameter maxResults : An optional limit for the number of resources returned in a single call.

Default value: 20

Parameter nextToken : The pagination token specifying which page of results to return in the response. If no token is provided, the default page is the first page.

Default value: null

Parameter speedUnit : The speed unit for the device captured by the device state. The measurement system must match for DistanceUnit and SpeedUnit; if Kilometers is specified for DistanceUnit, then SpeedUnit must be KilometersPerHour.

Default Value: KilometersPerHour.

Parameter timeHorizonMinutes : The forward-looking time window for forecasting, specified in minutes. The API only returns events that are predicted to occur within this time horizon. When no value is specified, this API performs a containment check. The containment check operation returns IDLE events for geofences where the device is currently inside of, but no other events.

Implementation

Future<ForecastGeofenceEventsResponse> forecastGeofenceEvents({
  required String collectionName,
  required ForecastGeofenceEventsDeviceState deviceState,
  DistanceUnit? distanceUnit,
  int? maxResults,
  String? nextToken,
  SpeedUnit? speedUnit,
  double? timeHorizonMinutes,
}) async {
  final $payload = <String, dynamic>{
    'DeviceState': deviceState,
    if (distanceUnit != null) 'DistanceUnit': distanceUnit.value,
    if (maxResults != null) 'MaxResults': maxResults,
    if (nextToken != null) 'NextToken': nextToken,
    if (speedUnit != null) 'SpeedUnit': speedUnit.value,
    if (timeHorizonMinutes != null) 'TimeHorizonMinutes': timeHorizonMinutes,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/geofencing/v0/collections/${Uri.encodeComponent(collectionName)}/forecast-geofence-events',
    exceptionFnMap: _exceptionFns,
  );
  return ForecastGeofenceEventsResponse.fromJson(response);
}