pixelYToLatitude method

double pixelYToLatitude(
  1. double pixelY
)

Converts a pixel Y coordinate at a certain map size to a latitude coordinate.

@param pixelY the pixel Y coordinate that should be converted. @param mapSize precomputed size of map. @return the latitude value of the pixel Y coordinate. @throws IllegalArgumentException if the given pixelY coordinate is invalid.

Implementation

double pixelYToLatitude(double pixelY) {
  assert(pixelY >= 0);
  assert(pixelY <= _mapSize);
  const double pi2 = 2 * pi;
  const double pi360 = 360 / pi;
  double y = 0.5 - (pixelY / _mapSize);
  return 90 - pi360 * atan(exp(-y * pi2));
}