Exemplo n.º 1
0
        //百度坐标转墨卡托
        public static PointF LatLng2Mercator(LatLngPoint p)
        {
            double[] arr   = null;
            double   n_lat = p.Lat > 74 ? 74 : p.Lat;

            n_lat = n_lat < -74 ? -74 : n_lat;
            for (var i = 0; i < array1.Length; i++)
            {
                if (p.Lat >= array1[i])
                {
                    arr = array2[i];
                    break;
                }
            }
            if (arr == null)
            {
                for (var i = array1.Length - 1; i >= 0; i--)
                {
                    if (p.Lat <= -array1[i])
                    {
                        arr = array2[i];
                        break;
                    }
                }
            }
            double[] res = Convertor(p.Lng, p.Lat, arr);
            return(new PointF((float)res[0], (float)res[1]));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 高德坐标系转换
        /// </summary>

        //高德经纬度坐标转瓦片坐标
        public static Point LatLng2TileXY(LatLngPoint p, int level)
        {
            int tileX = (int)Math.Floor(((p.Lng + 180) / 360) * Math.Pow(2, level));
            int tileY = (int)Math.Floor((1 - (Math.Log((Math.Tan(p.Lat * Math.PI / 180) + 1 / Math.Cos(p.Lat * Math.PI / 180))) / Math.PI)) * Math.Pow(2, level - 1));

            return(new Point(tileX, tileY));
        }
Exemplo n.º 3
0
        //高德经纬度坐标转像素坐标
        public static Point LatLng2PixelXY(LatLngPoint p, int level)
        {
            int pixelX = (int)Math.Floor((p.Lng + 180) / 360 * Math.Pow(2, level) * 256 % 256 + 0.5);
            int pixelY = (int)Math.Floor((1 - (Math.Log((Math.Tan(p.Lat * Math.PI / 180) + 1 / Math.Cos(p.Lat * Math.PI / 180))) / Math.PI)) * Math.Pow(2, level - 1) * 256 % 256 + 0.5);

            return(new Point(pixelX, pixelY));
        }