Esempio n. 1
0
        /// <summary>
        /// 经纬度转坐标(x,y)
        /// 256个MC单位对应1个Unit单位
        /// </summary>
        /// <param name="lngLat"></param>
        /// <returns></returns>
        public static Vector3 LngLat2Position(Vector2D lngLat)
        {
            //转换MC坐标
            Vector2D vector2D = MCTransform.ConvertLL2MC(lngLat);

            //缩小到Unit单位范围内(-100000, 100000)
            return(new Vector2((float)(vector2D.x / 256), (float)(vector2D.y / 256)));
        }
Esempio n. 2
0
        /// <summary>
        /// 将LngLat地理坐标系转换为tile瓦片坐标系
        /// </summary>
        /// <param name="lngLat">经纬度信息</param>
        /// <param name="zoom">缩放比例</param>
        /// <param name="pixelOffset">像素偏移</param>
        /// <returns></returns>
        public static TileData LngLat2Tile(Vector2D lngLat, int zoom, Vector2 pixelOffset)
        {
            TileData tileData = new TileData(zoom);
            //转换MC坐标
            Vector2D vector2D = MCTransform.ConvertLL2MC(lngLat);

            //转换到缩放级别
            vector2D *= Math.Pow(2, zoom - 18);
            //偏移像素
            vector2D        += pixelOffset;
            tileData.tile.x  = (int)(vector2D.x / 256.0);
            tileData.tile.y  = (int)(vector2D.y / 256.0);
            tileData.pixel.x = ((int)vector2D.x % 256);
            tileData.pixel.y = ((int)vector2D.y % 256);
            return(tileData);
        }