Coordinate systems conversion

This is my sample data.

```WGS84 datum (longitude/latitude):
-123.75 36.59788913307022
-118.125 40.97989806962013

Spherical Mercator (meters):
-13775786.985667605 4383204.9499851465
-13149614.849955441 5009377.085697312

Pixels
2560 6144 2816 6400

x:10, y:24, z:6

TMS
x:10, y:39, z:6

023010
```

I'm using the code from this source

How should I chain the methods in order to get from google tiles `(x:10, y:24, z:6)` the Sperical Mercator meters

```-13775786.985667605 4383204.9499851465
-13149614.849955441 5009377.085697312```
?

I have used lots of combinations but I'm getting wrong numbers. Thank you in advance.

-

This issue has been sleeping here for long, but this might help some googler:

For a similar task I simplified the functions from the website that you mention to the following, it works fine for me (in Python):

``````def LatLonToPixels(lat, lon, zoom):
tileSize = 256
sinLat = math.sin(float(lat) * (math.pi/180))
py = (0.5 - math.log((1 + sinLat) / (1 - sinLat)) / (4 * math.pi)) * tileSize * 2**float(zoom)
px = ((float(lon) + 180) / 360) * tileSize * 2**float(zoom)
return px, py

def PixelsToTile(px, py, service):
tileSize = 256
tx = int( math.ceil( px / float(tileSize) ) - 1 )
ty = int( math.ceil( py / float(tileSize) ) - 1 )
return tx, ty
``````

These two functions are very straightforward to use (less to get the maths behind it). You simply need to use the first one to get the coordinates in pixel of your longitude and latitude, and the second one to compute on which tile it is located.

The Bing help documents are really helpfull, have a look!

-