public abstract void GetTilePath(Tile tile);//下载tile

        /// <summary>
        /// 初始化
        /// </summary>
        protected virtual void Init()
        {
            downloadQueue.Clear();

            Tile         minTile;
            Tile         maxTile;
            DownloadZoom item;

            for (int i = minDownloadZoom; i <= maxDownloadZoom; i++)
            {
                minTile = Utility.GetTile(i, downloadExtent.MinLongitude, downloadExtent.MaxLatitude);
                maxTile = Utility.GetTile(i, downloadExtent.MaxLongitude, downloadExtent.MinLatitude);

                item = new DownloadZoom()
                {
                    Zoom     = i,
                    MinTileX = minTile.X,
                    MaxTileX = maxTile.X,
                    MinTileY = minTile.Y,
                    MaxTileY = maxTile.Y
                };

                if (downloadQueue.Count > 0)
                {
                    item.Prev = downloadQueue[downloadQueue.Count - 1];
                    downloadQueue[downloadQueue.Count - 1].Next = item;
                }
                item.Downloader = this;

                downloadQueue.Add(item);
            }

            downloadTileCount = (ulong)downloadQueue.Sum(d => d.TileCount);
        }
Esempio n. 2
0
        /// <summary>
        /// 更新下载记录状态
        /// </summary>
        /// <param name="downloadItem"></param>
        public static void UpdateDownloading(DownloadZoom downloadItem)
        {
            lock (lockInstance)
            {
                MapServerDownloader downloader = downloadItem.Downloader;
                XElement            eleUpdate;

                eleUpdate       = configDoc.Root.Element("downloadedTileCount");
                eleUpdate.Value = downloader.DownloadedTileCount.ToString();

                eleUpdate       = configDoc.Root.Element("curDownloadZoom");
                eleUpdate.Value = downloadItem.Zoom.ToString();

                XElement ele = configDoc.Root.Element("items").Elements()
                               .Where(e => e.Attribute("zoom").Value.Trim() == downloadItem.Zoom.ToString())
                               .FirstOrDefault();

                if (ele == null)
                {
                    return;
                }

                eleUpdate       = ele.Element("curTileX");
                eleUpdate.Value = downloadItem.CurTileX.ToString();

                eleUpdate       = ele.Element("curTileY");
                eleUpdate.Value = downloadItem.CurTileY.ToString();

                eleUpdate       = ele.Element("downloadedTileCount");
                eleUpdate.Value = downloadItem.DownloadedTileCount.ToString();

                Save();
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 将下载写到日志文件里
 /// </summary>
 /// <param name="downloadItem"></param>
 private static XElement DownloadZoomItemConfig(DownloadZoom downloadItem)
 {
     return(new XElement("item",
                         new XAttribute("zoom", downloadItem.Zoom.ToString())
                         , new XElement("minTileX", downloadItem.MinTileX.ToString())
                         , new XElement("maxTileX", downloadItem.MaxTileX.ToString())
                         , new XElement("minTileY", downloadItem.MinTileY.ToString())
                         , new XElement("maxTileY", downloadItem.MaxTileY.ToString())
                         , new XElement("tileCount", downloadItem.TileCount.ToString())
                         , new XElement("curTileX", downloadItem.CurTileX.ToString())
                         , new XElement("curTileY", downloadItem.CurTileY.ToString())
                         , new XElement("downloadedTileCount", downloadItem.DownloadedTileCount.ToString())));
 }
Esempio n. 4
0
        /// <summary>
        /// 读取一个下载层
        /// </summary>
        /// <param name="ele"></param>
        /// <returns></returns>
        public static DownloadZoom ReadDownloadZoom(XElement ele)
        {
            if (ele == null)
            {
                return(null);
            }

            DownloadZoom downloadZoom = new DownloadZoom();

            downloadZoom.Zoom     = int.Parse(ele.Attribute("zoom").Value);
            downloadZoom.MinTileX = long.Parse(ele.Element("minTileX").Value);
            downloadZoom.MaxTileX = long.Parse(ele.Element("maxTileX").Value);
            downloadZoom.MinTileY = long.Parse(ele.Element("minTileY").Value);
            downloadZoom.MaxTileY = long.Parse(ele.Element("maxTileY").Value);

            downloadZoom.CurTileX = long.Parse(ele.Element("curTileX").Value);
            downloadZoom.CurTileY = long.Parse(ele.Element("curTileY").Value);

            return(downloadZoom);
        }