convertCoordinates function
Position
convertCoordinates(
- Position coord,
- CoordinateSystem fromSystem,
- CoordinateSystem toSystem
Converts coordinates from one system to another.
Valid systems: CoordinateSystem.wgs84, CoordinateSystem.mercator Returns: Position in the target system
Implementation
Position convertCoordinates(
Position coord, CoordinateSystem fromSystem, CoordinateSystem toSystem) {
if (fromSystem == toSystem) {
return coord;
}
if (fromSystem == CoordinateSystem.wgs84 &&
toSystem == CoordinateSystem.mercator) {
return toMercator(coord);
} else if (fromSystem == CoordinateSystem.mercator &&
toSystem == CoordinateSystem.wgs84) {
return toWGS84(coord);
} else {
throw ArgumentError(
"Unsupported coordinate system conversion from ${fromSystem.runtimeType} to ${toSystem.runtimeType}");
}
}