tileIDFor static method

TileID tileIDFor(
  1. Point<num> point,
  2. int zm
)

Implementation

static TileID tileIDFor(math.Point point, int zm) {
  final zoom = clamp(zm.toDouble(), 0.0, _maxZoom);
  final n = math.pow(2.0, zoom);
  final lat = point.x;
  final lon = point.y;
  final sine = math.sin(lat * _degToRad);
  var x = n * (lon / 360.0 + 0.5);
  var y = n * (0.5 - 0.25 * math.log((1 + sine) / (1 - sine)) / math.pi);
  x %= n;
  if (x < 0) {
    x += n;
  }
  x = clamp(x.floorToDouble(), 0.0, double.maxFinite);
  y = clamp(y.floorToDouble(), 0.0, double.maxFinite);
  return TileID(x, y, zoom);
}