convert static method
- required Projection from,
- required ProjectionType toType,
- void onComplete(- GemError err,
- Projection? result
 
Async method that returns the projection result from an input projection.
Parameters
- IN type The type of projection to cast to.
- IN from The input projection that needs to be converted.
- IN onComplete Callback for the operation completion.
- err GemError The error code returned by the operation.
- GemError.success and a non-null Projection if the conversion was successfully completed
- GemError.notSupported and null if the conversion cannot be done
- GemError.internalAbort and null if the result parsing failed or server internal error occurred
 
Returns
- A TaskHandler that can be used to track the progress of the operation or null if it failed.
Implementation
static TaskHandler? convert({
  required Projection from,
  required ProjectionType toType,
  final void Function(GemError err, Projection? result)? onComplete,
}) {
  final EventDrivenProgressListener progListener =
      EventDrivenProgressListener();
  late Projection result;
  switch (toType) {
    case ProjectionType.bng:
      result = BNGProjection(easting: 0, northing: 0);
    case ProjectionType.lam:
      result = LAMProjection(x: 0, y: 0);
    case ProjectionType.utm:
      result =
          UTMProjection(x: 0, y: 0, zone: 0, hemisphere: Hemisphere.north);
    case ProjectionType.mgrs:
      result = MGRSProjection(easting: 0, northing: 0, zone: '', letters: '');
    case ProjectionType.gk:
      result = GKProjection(x: 0, y: 0, zone: 0);
    case ProjectionType.wgs84:
      result = WGS84Projection(Coordinates());
    case ProjectionType.w3w:
      result = W3WProjection('');
    case ProjectionType.undefined:
      throw UnimplementedError();
  }
  GemKitPlatform.instance.registerEventHandler(progListener.id, progListener);
  progListener.registerOnCompleteWithData((
    final int err,
    final String hint,
    final Map<dynamic, dynamic> json,
  ) {
    GemKitPlatform.instance.unregisterEventHandler(progListener.id);
    if (err == GemError.success.code) {
      onComplete?.call(GemErrorExtension.fromCode(err), result);
    } else {
      onComplete?.call(GemErrorExtension.fromCode(err), null);
    }
  });
  final OperationResult resultString = staticMethod(
    'ProjectionService',
    'convert',
    args: <String, dynamic>{
      'from': from._pointerId,
      'to': result._pointerId,
      'listener': progListener.id,
    },
  );
  final GemError errorCode =
      GemErrorExtension.fromCode(resultString['result']);
  if (errorCode != GemError.success) {
    onComplete?.call(errorCode, null);
    return null;
  }
  return TaskHandlerImpl(progListener.id);
}