convert method

  1. @override
GeographicArea? convert(
  1. GeographicAreaType toType
)
override

Converts the geographic area to another type, if possible.

Parameters

Returns

  • A GeographicArea object representing the converted area, or null if the conversion failed.

Implementation

@override
GeographicArea? convert(GeographicAreaType toType) {
  final OperationResult resultString = objectMethod(
    _pointerId,
    'TilesCollectionGeographicArea',
    'convert',
    args: toType.id,
  );

  if (resultString['gemApiError'] != 0) {
    return null;
  }

  switch (toType) {
    case GeographicAreaType.rectangle:
      return RectangleGeographicArea.fromJson(resultString.data['result']);
    case GeographicAreaType.circle:
      return CircleGeographicArea.fromJson(resultString['result']);
    case GeographicAreaType.polygon:
      return PolygonGeographicArea.fromJson(resultString['result']);
    case GeographicAreaType.tileCollection:
      return TilesCollectionGeographicArea.init(resultString['result']);
    case GeographicAreaType.undefined:
      return RectangleGeographicArea(
        topLeft: Coordinates(),
        bottomRight: Coordinates(),
      );
  }
}