convert method
Attempts to convert this geographic area to a different type.
Tries to create a new geographic area of the specified type that approximates the same spatial region. Conversion success depends on the source and target types - some conversions may result in loss of precision or may not be possible at all.
Parameters
toType: The desired target GeographicAreaType for conversion.
Returns
- A new GeographicArea of the requested type on successful conversion,
or
nullif conversion is not possible or fails.
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(),
);
}
}