Example #1
0
        /// <summary>
        /// 从管理器中获取瓦片(不加锁)
        /// </summary>
        /// <param name="zoom"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public Tile GetTileNoLock(int zoom, PointInt64 tileIndex)
        {
            Tile t = null;
            Dictionary <PointInt64, Tile> dic1;

            if (dicTile.TryGetValue(zoom, out dic1))
            {
                dic1.TryGetValue(tileIndex, out t);
            }
            else
            {
                dic1 = new Dictionary <PointInt64, Tile>();
                dicTile.Add(zoom, dic1);
            }
            //if (t==null)
            //{
            //    //瓦片不存在则添加到加载器中
            //    t = new Tile(tileIndex, zoom);
            //    //AddTile(t);
            //    if (ifNotExitsLoad)
            //    {
            //        LoadTile(t);
            //    }
            //}
            //t.ReadTime = DateTime.Now;
            return(t);
        }
Example #2
0
        protected void GetSecureWords(PointInt64 pos, out string sec1, out string sec2)
        {
            sec1 = string.Empty; // after &x=...
            sec2 = string.Empty; // after &zoom=...
            int seclen = (int)((pos.X * 3) + pos.Y) % 8;

            sec2 = SecureWord.Substring(0, seclen);
            if (pos.Y >= 10000 && pos.Y < 100000)
            {
                sec1 = Sec1;
            }
        }
Example #3
0
        /// <summary>
        /// 从管理器中获取瓦片(支持多线程并发获取)
        /// </summary>
        /// <param name="zoom"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public Tile GetTile(int zoom, PointInt64 tileIndex)
        {
            Tile t = null;

            TilesFastLock.AcquireReaderLock(_lockTimeOut);
            try
            {
                t = GetTileNoLock(zoom, tileIndex);
            }
            finally
            {
                TilesFastLock.ReleaseReaderLock();
            }
            return(t);
        }
Example #4
0
        /// <summary>
        /// 根据层级获取矩形区域内的所有瓦片索引
        /// </summary>
        public static List <PointInt64> GetAreaTileList(RectLatLng rect, int zoom, int padding = 0)
        {
            List <PointInt64> ret = new List <PointInt64>();

            PointInt64 topLeft     = PixelToTileXY(LatLngToPixel(rect.LeftTop, zoom));
            PointInt64 rightBottom = PixelToTileXY(LatLngToPixel(rect.RightBottom, zoom));

            for (long x = (topLeft.X - padding); x <= (rightBottom.X + padding); x++)
            {
                for (long y = (topLeft.Y - padding); y <= (rightBottom.Y + padding); y++)
                {
                    PointInt64 p = new PointInt64(x, y);
                    if (!ret.Contains(p) && p.X >= 0 && p.Y >= 0)
                    {
                        ret.Add(p);
                    }
                }
            }

            return(ret);
        }
Example #5
0
 public static Point ToPoint(this PointInt64 p)
 {
     return(new Point((int)p.X, (int)p.Y));
 }
Example #6
0
 /// <summary>
 /// 根据瓦片索引和瓦片尺寸获取像素坐标
 /// </summary>
 /// <param name="p"></param>
 /// <param name="tileSize"></param>
 /// <returns></returns>
 public static PointInt64 TileXYToPixel(PointInt64 p, SizeInt tileSize)
 {
     return(new PointInt64((p.X * tileSize.Width), (p.Y * tileSize.Height)));
 }
Example #7
0
 protected static int GetServerNum(PointInt64 pos, int max)
 {
     return((int)(pos.X + 2 * pos.Y) % max);
 }
Example #8
0
 /// <summary>
 /// 根据瓦片索引和瓦片尺寸获取像素坐标
 /// </summary>
 /// <param name="p"></param>
 /// <param name="tileSize"></param>
 /// <returns></returns>
 public static PointInt64 TileXYToPixel(PointInt64 p)
 {
     return(MapHelper.TileXYToPixel(p, TileSize));
 }