Example #1
0
        /// <summary>
        /// 百度经纬度转Tile值
        /// </summary>
        /// <param name="lng">经度</param>
        /// <param name="lat">纬度</param>
        /// <param name="zoom">缩放级别</param>
        /// <returns></returns>
        public static TileXY BDlatlng2TileXY(double lng, double lat, int zoom)//x,y百度坐标 zoom 放大级别
        {
            MercatorPoint p  = BDLatLng2Mercator(new GeoLatLng(lat, lng));
            double        x1 = p.x / Math.Pow(2, 18 - zoom) / 256;
            double        y1 = p.y / Math.Pow(2, 18 - zoom) / 256;

            x1 = Math.Pow(2, zoom - 26) * (PI * lng * r / 180);
            y1 = Math.Pow(2, zoom - 26) * r * Math.Log(Math.Tan(PI * lat / 180) + 1 / Math.Cos(PI * lat / 180));
            return(new TileXY((int)x1, (int)y1, zoom));
        }
Example #2
0
        /// <summary>
        /// 墨卡托转百度经纬度
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public static GeoLatLng Mercator2BDLatLng(MercatorPoint p)
        {
            double[]      arr = null;
            MercatorPoint np  = new MercatorPoint(Math.Abs(p.x), Math.Abs(p.x));

            for (var i = 0; i < array3.Length; i++)
            {
                if (np.y >= array3[i])
                {
                    arr = array4[i];
                    break;
                }
            }
            double[] res = BDConvertor(np.x, np.y, arr);
            return(new GeoLatLng(res[1], res[0]));
        }