importLandmarksWithDataBuffer method
Asynchronously import landmarks from given buffer format
Parameters
- IN buffer The data buffer.
- IN format The file format, see LandmarkFileFormat.
- IN image The landmark map image. If left empty, a default image is assigned
- IN onProgressUpdated Callback that gets triggered with the associated progress when the update process is in progress.
- IN onCompleteCallback Callback that gets triggered with the associated GemError when the update process is completed.
- Is called with GemError.success if the operation suceeded
- Is called with GemError.inUse if an import is already in progress
- Is called with GemError.notFound if the landmark store category id is invalid
- Is called with GemError.cancel if the operation was canceled
- Is called with GemError.invalidInput if the provided data could not be parsed
- IN categoryId The category for the new imported landmarks. The category must exist or use uncategorizedLandmarkCategId to set the landmark as uncategorized
Returns
- The associated ProgressListener if the request can be started, null otherwise.
Throws
- An exception if it fails to initialize.
Implementation
ProgressListener? importLandmarksWithDataBuffer({
required Uint8List buffer,
required LandmarkFileFormat format,
required Img image,
final void Function(GemError error)? onCompleteCallback,
final void Function(int progress)? onProgressUpdated,
int categoryId = uncategorizedLandmarkCategId,
}) {
final EventDrivenProgressListener progressListener =
EventDrivenProgressListener();
if (onCompleteCallback != null) {
progressListener.registerOnCompleteWithDataCallback(
(final int err, final String hint, final Map<dynamic, dynamic> json) =>
onCompleteCallback(GemErrorExtension.fromCode(err)),
);
}
if (onProgressUpdated != null) {
progressListener.registerOnProgressCallback(onProgressUpdated);
}
GemKitPlatform.instance.registerEventHandler(
progressListener.id,
progressListener,
);
final dynamic dataBufferPointer = GemKitPlatform.instance.toNativePointer(buffer);
final OperationResult resultString = objectMethod(
_pointerId,
'LandmarkStore',
'importLandmarksWithDataBuffer',
args: <String, dynamic>{
'dataBuffer': dataBufferPointer.address,
'dataBufferSize': buffer.length,
'fileFormat': format.id,
'image': image.pointerId,
'categoryId': categoryId,
'listener': progressListener.id,
},
);
GemKitPlatform.instance.freeNativePointer(dataBufferPointer);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
onCompleteCallback?.call(errorCode);
return null;
}
return progressListener;
}