示例#1
0
        public Uri BuildUri(ImageryProvider provider, int x, int y, int zoom)
        {
            string[] serverNodes = provider.UrlModel.Servers;
            string   server      = string.Empty;

            if (serverNodes != null && serverNodes.Length > 0)
            {
                _serverCycle = (_serverCycle + 1) % serverNodes.Length;
                server       = serverNodes[_serverCycle];
            }

            string url = provider.UrlModel.UrlFormat;

            url = url.Replace("{s}", server);
            url = url.Replace("{x}", x.ToString());
            url = url.Replace("{y}", y.ToString());
            url = url.Replace("{z}", zoom.ToString());
            url = url.Replace("{quadkey}", TileUtils.TileXYToQuadKey(x, y, zoom));
            if (url.Contains("{t}"))
            {
                var token = GetToken(provider);
                if (String.IsNullOrWhiteSpace(token))
                {
                    var message =
                        $"There is no token found for {provider.Name} provider. Make sure a user secrets are set with a {provider.TokenUserSecretsKey} value.";
                    _logger?.LogError(message);
                    throw new Exception(message);
                }

                url = url.Replace("{t}", token);
            }

            return(new Uri(url, UriKind.Absolute));
        }
示例#2
0
        public MapTileInfo ZoomIn(string quadIndex)
        {
            if (Zoom == 23)
            {
                return(this);
            }

            TileUtils.QuadKeyToTileXY(string.Concat(TileUtils.TileXYToQuadKey(X, Y, Zoom), quadIndex), out int x0, out int y0, out int z0);
            return(new MapTileInfo(x0, y0, z0, this.TileSize));
        }
示例#3
0
        public MapTileInfo ZoomOut()
        {
            if (Zoom == 1)
            {
                return(this);
            }

            var quadKey = TileUtils.TileXYToQuadKey(X, Y, Zoom);

            TileUtils.QuadKeyToTileXY(quadKey.Substring(0, quadKey.Length - 1), out int x0, out int y0, out int z0);
            return(new MapTileInfo(x0, y0, z0, this.TileSize));
        }