Пример #1
0
        /// <summary>
        /// 瓦片坐标转墨卡坐标
        /// </summary>
        /// <param name="tile"></param>
        /// <param name="zoom"></param>
        /// <returns></returns>
        public static LanLat TileToMercato(ref TilePos tile, int zoom)
        {
            int    s = 1 << (18 - zoom);
            double x = tile.x * 256 + tile.ox;

            x *= s;
            double y = tile.y * 256 + tile.oy;

            y *= s;
            var ll = new LanLat();

            ll.x = x;
            ll.y = y;
            return(ll);
        }
Пример #2
0
        /// <summary>
        /// 墨卡坐标转瓦片坐标
        /// </summary>
        /// <param name="ll"></param>
        /// <param name="zoom">3-18</param>
        public static TilePos MercatoToTile(LanLat ll, int zoom)
        {
            int    s  = 1 << (18 - zoom);
            double tx = ll.x / s;
            double mx = tx / 256;
            double rx = tx % 256;
            double ty = ll.y / s;
            double my = ty / 256;
            double ry = ty % 256;
            var    ti = new TilePos();

            ti.x  = (int)mx;
            ti.y  = (int)my;
            ti.ox = (float)rx;
            ti.oy = (float)ry;
            return(ti);
        }