public override Uri GetUri(int x, int y, int zoomLevel) { Uri uri = null; if (UriTemplate != null) { var tileSize = 360d / (1 << zoomLevel); // tile width in degrees var west = MapProjection.Wgs84MeterPerDegree * (x * tileSize - 180d); var east = MapProjection.Wgs84MeterPerDegree * ((x + 1) * tileSize - 180d); var south = MapProjection.Wgs84MeterPerDegree * (180d - (y + 1) * tileSize); var north = MapProjection.Wgs84MeterPerDegree * (180d - y * tileSize); if (UriTemplate.Contains("{bbox}")) { uri = new Uri(UriTemplate.Replace("{bbox}", string.Format(CultureInfo.InvariantCulture, "{0:F2},{1:F2},{2:F2},{3:F2}", west, south, east, north))); } else { uri = new Uri(UriTemplate .Replace("{west}", west.ToString("F2", CultureInfo.InvariantCulture)) .Replace("{south}", south.ToString("F2", CultureInfo.InvariantCulture)) .Replace("{east}", east.ToString("F2", CultureInfo.InvariantCulture)) .Replace("{north}", north.ToString("F2", CultureInfo.InvariantCulture))); } } return(uri); }
public override string ToString() { var stringBuilder = new StringBuilder(); stringBuilder.Append("["); stringBuilder.Append($"UriTemplate = '{UriTemplate.Replace("{", "{{").Replace("}", "}}")}', "); stringBuilder.Append($"UriTemplateRegex = '{UriTemplateRegex.ToString().Replace("{", "{{").Replace("}", "}}")}'"); stringBuilder.Append("]"); return(stringBuilder.ToString()); }
public override Uri GetUri(int x, int y, int zoomLevel) { Uri uri = null; if (UriTemplate != null && TileMatrixSet != null && TileMatrixSet.TileMatrixes.Count > zoomLevel && x >= 0 && y >= 0 && zoomLevel >= 0) { uri = new Uri(UriTemplate .Replace("{TileMatrixSet}", TileMatrixSet.Identifier) .Replace("{TileMatrix}", TileMatrixSet.TileMatrixes[zoomLevel].Identifier) .Replace("{TileCol}", x.ToString()) .Replace("{TileRow}", y.ToString())); } return(uri); }
public override Uri GetUri(int x, int y, int zoomLevel) { Uri uri = null; if (UriTemplate != null && Subdomains != null && Subdomains.Length > 0 && zoomLevel > 0) { var subdomain = Subdomains[(x + y) % Subdomains.Length]; var quadkey = new char[zoomLevel]; for (var z = zoomLevel - 1; z >= 0; z--, x /= 2, y /= 2) { quadkey[z] = (char)('0' + 2 * (y % 2) + (x % 2)); } uri = new Uri(UriTemplate .Replace("{subdomain}", subdomain) .Replace("{quadkey}", new string(quadkey))); } return(uri); }