欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

经纬度与web墨卡托相互转换

程序员文章站 2022-04-04 12:14:40
...

        public static double[] Mercator2LonLat(double X, double Y)
        {
            double[] d = new double[2];
            double x = X / 20037508.34 * 180;
            double y = Y / 20037508.34 * 180;
            y = 180 / Math.PI * (2 * Math.Atan(Math.Exp(y * Math.PI / 180)) - Math.PI / 2);
            d[0] = x;
            d[1] = y;
            return d;
        }

        public static double[] LonLat2Mercator(double X, double Y)
        {
            double[] d = new double[2];
            double x = X * 20037508.34 / 180;
            double y = Math.Log(Math.Tan((90 + Y) * Math.PI / 360)) / (Math.PI / 180);
            y = y * 20037508.34 / 180;
            d[0] = x;
            d[1] = y;
            return d;
        }

 

相关标签: 坐标转换