tile2Lat method

double tile2Lat(
  1. num y,
  2. num z
)

converts tile y to latitude. if the latitude is out of range it is adjusted to the min/max latitude (-90,90)

Implementation

double tile2Lat(num y, num z) {
  var yBounded = math.max(y, 0);
  var n = math.pow(2.0, z);
  var latRad = math.atan(_sinh(math.pi * (1 - 2 * yBounded / n)));
  var latDeg = latRad * 180 / math.pi;
  //keep the point in the world
  return latDeg > 0
      ? math.min(latDeg, 90).toDouble()
      : math.max(latDeg, -90).toDouble();
}