invert method

  1. @override
(double, double) invert(
  1. double x,
  2. double y
)
override

Inverts screen coordinates to geographic longitude, latitude.

Implementation

@override
(double, double) invert(double x, double y) {
  final (rawY, rawX) = removeTransform(x, y);

  final sinhY = (math.exp(rawY) - math.exp(-rawY)) / 2;
  final cosX = math.cos(-rawX);
  final sinX = math.sin(-rawX);

  final longitude = toDegrees(math.atan2(sinhY, cosX)) + centerLon;
  final latitude = toDegrees(
      math.asin(sinX / math.sqrt(sinhY * sinhY + cosX * cosX + sinX * sinX)));

  return (clampLongitude(longitude), clampLatitude(latitude));
}