我有一个墨卡托投影图作为JPEG,我想知道如何将给定的x,y坐标与其纬度和经度相关联.我看过Gudermannian函数,但老实说我不明白如何使用该函数并应用它.即,它期待什么输入?我发现的实现(JavaScript)似乎在-PI和PI之间取得了一个范围,但是我的y值(以像素为单位)与该范围之间的相关性是什么?
此外,我发现这个功能需要一个纬度并返回谷歌地图的瓷砖,谷歌地图也使用墨卡托.似乎如果我知道如何反转这个功能,我会非常接近我的答案.
/*<summary>Get the vertical tile number from a latitude
using Mercator projection formula</summary>*/
private int getMercatorLatitude(double lati)
{
double maxlat = Math.PI;
double lat = lati;
if (lat > 90) lat = lat - 180;
if (lat < -90) lat = lat + 180;
// conversion degre=>radians
double phi = Math.PI * lat / 180;
double res;
//double temp = Math.Tan(Math.PI / 4 - phi / 2);
//res = Math.Log(temp);
res = 0.5 * Math.Log((1 + Math.Sin(phi)) / (1 …Run Code Online (Sandbox Code Playgroud)