importLandmarksWithDataBuffer method
Asynchronously imports landmarks into this store from a raw data buffer.
Use this when landmark data is available directly in memory (for example downloaded or received over a network). Parameters and completion semantics match importLandmarks.
Parameters
buffer: Binary data containing the landmark file content.format: The LandmarkFileFormat of the buffer.image: An Img used as the landmark image for imported items.onComplete: Optional callback invoked with a GemError when the import finishes.- 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
onProgressUpdated: Optional progress callback (0-100).categoryId: Optional category id to assign to imported landmarks.
Returns
- ProgressListener?: A progress listener if the import started, otherwise null.
See also:
- importLandmarks — imports landmarks from a file path.
Implementation
ProgressListener? importLandmarksWithDataBuffer({
required Uint8List buffer,
required LandmarkFileFormat format,
required Img image,
final void Function(GemError error)? onComplete,
final void Function(int progress)? onProgressUpdated,
int categoryId = uncategorizedLandmarkCategId,
}) {
final EventDrivenProgressListener progressListener =
EventDrivenProgressListener();
if (onComplete != null) {
progressListener.registerOnCompleteWithData(
(final int err, final String hint, final Map<dynamic, dynamic> json) =>
onComplete(GemErrorExtension.fromCode(err)),
);
}
if (onProgressUpdated != null) {
progressListener.registerOnProgress(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) {
onComplete?.call(errorCode);
return null;
}
return progressListener;
}