createSimulationDataSource static method

DataSource? createSimulationDataSource(
  1. Route route, {
  2. ImproveMode improveMode = ImproveMode.sensorFusionWithMapMatching,
})

Create a simulated data source from a Route.

The returned DataSource will simulate sensor data based on the provided route and can be used for testing or replay scenarios.

Usually simulation on a given route is done via the NavigationService.startSimulation method.

Parameters

  • route: The Route to simulate.
  • improveMode: Specifies how raw sensor data is processed to generate an improved position estimate (e.g., sensor fusion or dead reckoning). The selected mode affects the internal processing pipeline applied on incoming data. Defaults to ImproveMode.sensorFusionWithMapMatching.

Returns

  • DataSource: The created simulation source, owned by the caller: drive it with start and stop, and release it with dispose.
  • null: route is no longer alive on the native side, or the engine refused the source. The underlying GemError is not surfaced.

Implementation

static DataSource? createSimulationDataSource(
  Route route, {
  ImproveMode improveMode = ImproveMode.sensorFusionWithMapMatching,
}) {
  final String resultString = GemKitPlatform.instance.callCreateObject(
    jsonEncode(<String, Object>{
      'class': 'DataSourceContainer',
      'args': <String, dynamic>{
        'type': 'simulation',
        'routeId': route.pointerId,
        'improveMode': improveMode.id,
      },
    }),
  );
  final dynamic decodedVal = jsonDecode(resultString);

  final int gemApiError = decodedVal['gemApiError'];

  if (GemErrorExtension.isErrorCode(gemApiError)) {
    return null;
  }

  final DataSource retVal = DataSource.init(decodedVal['result']);
  return retVal;
}