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 (rawX, rawY) = removeTransform(x, y);
  final adjustedY = -rawY;

  final rho0MinusY = _rho0 - adjustedY;
  final rho = math.sqrt(rawX * rawX + rho0MinusY * rho0MinusY) * _n.sign;

  final theta = math.atan2(rawX, rho0MinusY);
  final phi =
      math.asin(((_c - rho * rho * _n * _n) / (2 * _n)).clamp(-1.0, 1.0));

  final longitude = toDegrees(theta / _n) + centerLon;
  final latitude = toDegrees(phi);

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