Ejemplo n.º 1
0
        /// <summary>
        /// 获取地图块拼接信息
        /// </summary>
        /// <param name="box"></param>
        /// <param name="size"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        public ArrayList GetAllmapPieceInfo(BoundingBox box, int level)
        {
            ArrayList list = new ArrayList();

            PauseMapViewInfo PI          = new PauseMapViewInfo(box, level);
            SogouMapInfo     maptypeinfo = new SogouMapInfo();

            //计算第一个图片块的左上角所处图像位置
            PointD p = maptypeinfo.PixelToImage(PI.topPoint, new PointD(box.Min.X, box.Max.Y), level);

            #region 计算图片
            int Width   = PI.maxColIndex - PI.minColIndex + 1;
            int Height  = PI.maxRowIndex - PI.minRowIndex + 1;
            int centerX = (Width - 1) / 2;
            int centerY = (Height - 1) / 2;
            int intTest = 0;
            for (int rowIndex = PI.minRowIndex; rowIndex <= PI.maxRowIndex; rowIndex++)
            {
                for (int colIndex = PI.minColIndex; colIndex <= PI.maxColIndex; colIndex++)
                {
                    intTest++;
                    Rectangle destRect = new Rectangle((colIndex - PI.minColIndex) * maptypeinfo.tileSize + (int)Math.Round(p.X), (rowIndex - PI.minRowIndex) * maptypeinfo.tileSize + (int)Math.Round(p.Y), maptypeinfo.tileSize, maptypeinfo.tileSize);
                    string    filename = ZYB.GIS.GoogleMapType.GetFileName(colIndex, rowIndex, level);
                    Rectangle srcRect  = new Rectangle(0, 0, maptypeinfo.tileSize, maptypeinfo.tileSize);

                    MapPieceInfo mp = new MapPieceInfo();

                    int x = colIndex - PI.minColIndex;
                    int y = rowIndex - PI.minRowIndex;

                    mp.Priority = (x - centerX) * (x - centerX) + (y - centerY) * (y - centerY);
                    mp.filename = filename;
                    mp.destRect = destRect;
                    mp.srcRect  = srcRect;

                    list.Add(mp);
                }
            }
            string ww = intTest.ToString();
            #endregion

            return(RePrioritymapPiece(list));
        }
Ejemplo n.º 2
0
            /// <summary>
            /// zyb081217 获取可见区域的地图块及相关信息
            /// </summary>
            /// <param name="pTop"></param>
            /// <param name="level"></param>
            /// <param name="width"></param>
            /// <param name="height"></param>
            public PauseMapViewInfo(BoundingBox box, int level)
            {
                SogouMapInfo maptypeinfo = new SogouMapInfo();

                levelSize = (int)Math.Pow(2, level);
                PointD maxPoint = maptypeinfo.projection.LatLngToPixel(box.Max);
                PointD minPoint = maptypeinfo.projection.LatLngToPixel(box.Min);

                minColIndex = (int)Math.Floor((minPoint.X - maptypeinfo.PixelMaxBox.Min.X) / (maptypeinfo.PixelMaxBox.Max.X - maptypeinfo.PixelMaxBox.Min.X) * (double)levelSize);
                maxColIndex = (int)Math.Floor((maxPoint.X - maptypeinfo.PixelMaxBox.Min.X) / (maptypeinfo.PixelMaxBox.Max.X - maptypeinfo.PixelMaxBox.Min.X) * (double)levelSize);

                minRowIndex = (int)Math.Floor((maptypeinfo.PixelMaxBox.Max.Y - maxPoint.Y) / (maptypeinfo.PixelMaxBox.Max.Y - maptypeinfo.PixelMaxBox.Min.Y) * (double)levelSize);
                maxRowIndex = (int)Math.Floor((maptypeinfo.PixelMaxBox.Max.Y - minPoint.Y) / (maptypeinfo.PixelMaxBox.Max.Y - maptypeinfo.PixelMaxBox.Min.Y) * (double)levelSize);

                if (minColIndex < 0)
                {
                    minColIndex = 0;
                }
                if (minRowIndex < 0)
                {
                    minRowIndex = 0;
                }
                if (maxColIndex >= levelSize)
                {
                    maxColIndex = levelSize - 1;
                }
                if (maxRowIndex >= levelSize)
                {
                    maxRowIndex = levelSize - 1;
                }

                float topX = ((float)minColIndex / (float)levelSize) * (float)(maptypeinfo.PixelMaxBox.Max.X - maptypeinfo.PixelMaxBox.Min.X) + (float)maptypeinfo.PixelMaxBox.Min.X;
                float topY = (float)maptypeinfo.PixelMaxBox.Max.Y - ((float)minRowIndex / (float)levelSize) * (float)(maptypeinfo.PixelMaxBox.Max.Y - maptypeinfo.PixelMaxBox.Min.Y);

                topPoint = new PointD(topX, topY);

                this.nowColIndex = minColIndex;
                this.nowRowIndex = minRowIndex;
            }
Ejemplo n.º 3
0
 public SogouMap(string strFilePathBin, string strFilePathInfo)
 {
     this.strFilePathBin  = strFilePathBin;
     this.strFilePathInfo = strFilePathInfo;
     mapInfo = new SogouMapInfo();
 }