createExternalDataSource static method
DataSource?
createExternalDataSource(
- List<
DataType> dataTypes, { - ImproveMode improveMode = ImproveMode.sensorFusionWithMapMatching,
Create a new external data source.
Creates a DataSource fed by the caller through pushData. The improve pipeline is built
at creation time, so dataTypes must already declare the input improveMode consumes.
Parameters
dataTypes: The list of data types the external source provides. It must declare the inputimproveModeconsumes, listed on each ImproveMode value. Other types may be added as extra inputs but never satisfy this requirement on their own.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 source, owned by the caller: drive it with start and stop,
and release it with
dispose. null: The engine refused the source, i.e.dataTypesis empty or declares no input forimproveMode. The underlying GemError is not surfaced.
Implementation
static DataSource? createExternalDataSource(
List<DataType> dataTypes, {
ImproveMode improveMode = ImproveMode.sensorFusionWithMapMatching,
}) {
final List<int> intList = dataTypes
.map((DataType dataType) => dataType.id)
.toList();
final String resultString = GemKitPlatform.instance.callCreateObject(
jsonEncode(<String, Object>{
'class': 'DataSourceContainer',
'args': <String, Object>{
'availableDataType': intList,
'type': 'external',
'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;
}