コード例 #1
0
        protected string GetImagePath(TileIndex index)
        {
            var normalizedIndex = MapTileProvider.NormalizeIndex(index);

            string id = GetNameByIndex(normalizedIndex);

            string zoomDirPath = GetZoomDir(index.Level);
            string imagePath   = Path.Combine(zoomDirPath, GetFileName(id));

            return(imagePath);
        }
コード例 #2
0
        public override void BeginLoadImage(TileIndex id)
        {
            VerifyTileIndex(id);

            string uri = CreateRequestUriCore(MapTileProvider.NormalizeIndex(id));

            bool useMultipleServers = ServersNum != 0;

            if (useMultipleServers)
            {
                CurrentServer++;
                if (CurrentServer >= MinServer + ServersNum)
                {
                    CurrentServer = MinServer;
                }
            }

            if (runningDownloadsNum >= MaxConcurrentDownloads)
            {
                lock (waitingIDs)
                    waitingIDs.Push(id);
                return;
            }

            MapsTraceSource.Instance.ServerInformationTraceSource.TraceInformation("\"{0}\" - began to load url=\"{1}\"", GetCustomName(), uri);

            WebRequest request = WebRequest.Create(uri);

            AdjustRequest(request);

            runningDownloadsNum++;

            // this is hack to prevent freezing when request.BeginGetResponse was called
            // at the 1st time
            if (!firstCall)
            {
                request.BeginGetResponse(ResponseReadyCallback,
                                         new ResponseCallbackInfo {
                    ID = id, Request = request
                });
            }
            else
            {
                ThreadPool.QueueUserWorkItem(dummy => {
                    //Task.Create(o =>
                    //{
                    request.BeginGetResponse(ResponseReadyCallback, new ResponseCallbackInfo {
                        ID = id, Request = request
                    });
                    //}).WithExceptionThrowingInDispatcher(Dispatcher);
                });
            }
        }
コード例 #3
0
 public TileIndex Normalize()
 {
     return(MapTileProvider.NormalizeIndex(this));
 }