1

I have a point with the following coordinates 42.66959/23.32365 and I am trying to find the name of the tile generated by GeoServer for zoom level 18.

The projection used for generation is : WGS 84 / Pseudo-Mercator

This is code I use (JavaScript)

function latLonToTileNumber(lat, lon, zoom) {
  var lat_rad = lat * (Math.PI / 180);
  var x = (lon + 180) / 360 * Math.pow(2, zoom);
  var y = (1 - Math.log(Math.tan(lat_rad) + 1 / Math.cos(lat_rad)) / Math.PI) / 2 * Math.pow(2, zoom);
  return { x: Math.floor(x), y: Math.floor(y) };
}

The result is {x: 148055, y: 96652}. By checking the tile for this coordinate manually I found it is 00148055_00165491 , which makes me think that my Y formula is wrong.

enter image description here

So how can I calculate the tile number for these coordinates correctly?

Vince
  • 20,017
  • 15
  • 45
  • 64
Philip St
  • 21
  • 3

0 Answers0