XyzRasterTileSource¶
Namespace: ThinkGeo.Core
Raster tiles from any XYZ tile server: a URL template with {z}, {x} and {y} holes, fetched over HTTP on the standard 256-pixel web-mercator pyramid.
public class XyzRasterTileSource : RasterTileSource, System.IDisposable
Inheritance object → RasterTileSource → XyzRasterTileSource
Implements IDisposable
Remarks:
A tile the server answers 404 for is treated as empty coverage, not an error - the renderer draws the levels around it. Anything a URL template cannot express (authentication headers, quadkeys, local archives) is what implementing RasterTileSource directly is for.
Several templates spread requests over sibling hosts, which is what a public tile service usually asks for. The host is chosen from the tile coordinates rather than at random, so one tile always resolves to one host and a shared cache stores it once instead of once per host.
Properties¶
TileSize¶
public int TileSize { get; }
Property Value¶
UserAgent¶
The HTTP user agent sent with every tile request. Public tile servers commonly require an identifying one.
public string UserAgent { get; set; }
Property Value¶
TileCache¶
Where fetched tiles are kept between runs. Null fetches every time; a public tile service's usage policy usually asks for one.
public RasterTileCache TileCache { get; set; }
Property Value¶
WebProxy¶
The proxy tile requests go through, or null for the system default.
public IWebProxy WebProxy { get; set; }
Property Value¶
TimeoutInSeconds¶
How long one tile request may take before it is abandoned.
public int TimeoutInSeconds { get; set; }
Property Value¶
IsOpen¶
public bool IsOpen { get; }
Property Value¶
TileMatrixSet¶
Gets the tile grid this source PUBLISHES on: one TileMatrix per zoom level, indexed by zoom. The native grid, or the reprojection target when the tiles are being republished onto another grid.
public TileMatrixSet TileMatrixSet { get; }
Property Value¶
DrawsFallbackTiles¶
Gets or sets a value indicating whether a tile of this source, magnified from a shallower zoom, is worth showing while the tiles for the current one arrive.
public bool DrawsFallbackTiles { get; set; }
Property Value¶
Remarks:
True for imagery, and the default: a magnified aerial is a blurred version of the truth, in the right place, and it beats a hole in the map for the second or two the new tiles take.
Set it false for a source whose tiles are symbols drawn at a fixed size - a WMS of points or labels on nothing. Magnifying one of those does not blur it; it draws the symbols at the wrong size, beside the correctly sized ones in the cells that have already arrived. Measured on a service taking 1.2 s a tile, that is the whole of the transition. With this false the cells simply stay empty until their own tiles come, and whatever is under the layer shows through.
It says nothing about tiles that have arrived. A loaded tile always replaces the zoom beneath it across its whole footprint, transparent pixels included.
https://community.thinkgeo.com/t/bug-gpu-raster-tiles-from-previous-zooms-remain-visible/12479
MinDataZoom¶
The shallowest zoom level tiles exist at. A subclass that learns the range from the data - an archive header, a service capability - records it through at open.
public int MinDataZoom { get; }
Property Value¶
MaxDataZoom¶
The deepest zoom level tiles exist at; deeper views reuse this level's tiles (overzoom). See RasterTileSource.MinDataZoom.
public int MaxDataZoom { get; }
Property Value¶
Constructors¶
XyzRasterTileSource(string, int)¶
Initializes a source over , e.g. "https://tile.openstreetmap.org/{z}/{x}/{y}.png".
public XyzRasterTileSource(string uriTemplate, int maxZoom)
Parameters¶
uriTemplate string
The tile URL with {z}, {x}, {y} holes.
maxZoom int
The deepest level the server publishes tiles at; deeper views reuse that level's tiles (overzoom).
XyzRasterTileSource(IEnumerable<string>, int)¶
Initializes a source over several templates for the same tileset.
public XyzRasterTileSource(IEnumerable<string> uriTemplates, int maxZoom)
Parameters¶
uriTemplates IEnumerable<string>
The tile URLs, each with {z}, {x}, {y} holes.
maxZoom int
The deepest level the server publishes tiles at.
XyzRasterTileSource(string, TileMatrixSet, int)¶
Initializes a source whose tiles are addressed on a grid other than the web mercator one - a national XYZ service, published on its own projection.
public XyzRasterTileSource(string uriTemplate, TileMatrixSet tileMatrixSet, int maxZoom)
Parameters¶
uriTemplate string
The tile URL with {z}, {x}, {y} holes.
tileMatrixSet TileMatrixSet
The grid the SERVICE addresses its tiles on, from its own documentation: z/x/y go
to the server in terms of this. It is not the grid a map is drawn on - to put this
service under a map on another grid, call
with the map's.
maxZoom int
The deepest level the server publishes tiles at.
XyzRasterTileSource(IEnumerable<string>, TileMatrixSet, int)¶
Initializes a source over several templates whose tiles are addressed on a grid other than the web mercator one.
public XyzRasterTileSource(IEnumerable<string> uriTemplates, TileMatrixSet tileMatrixSet, int maxZoom)
Parameters¶
uriTemplates IEnumerable<string>
The tile URLs, each with {z}, {x}, {y} holes.
tileMatrixSet TileMatrixSet
The grid the service addresses its tiles on, or null for web mercator.
maxZoom int
The deepest level the server publishes tiles at.
Methods¶
OpenAsync(CancellationToken)¶
public Task OpenAsync(CancellationToken cancellationToken)
Parameters¶
cancellationToken CancellationToken
Returns¶
GetTileImageAsyncCore(int, long, long, CancellationToken)¶
protected Task<Byte[]> GetTileImageAsyncCore(int zoom, long x, long y, CancellationToken cancellationToken)
Parameters¶
zoom int
x long
y long
cancellationToken CancellationToken
Returns¶
Dispose(bool)¶
Releases the HTTP client.
protected void Dispose(bool disposing)
Parameters¶
disposing bool
Returns¶
Events¶
SendingHttpRequest¶
Raised before each tile request is sent. Rewrite the request to inject an API key, a signed URL or authentication headers; set Cancel to skip the request. This is how keyed providers plug in without a dedicated class.
public event EventHandler<SendingHttpRequestMessageEventArgs> SendingHttpRequest;
DataChanged¶
Raised when the tiles this source serves have changed - by RasterTileSource.Refresh(RectangleShape) - with the ground they changed over, null for all of it. The map listens and asks again.
public event EventHandler<TileSourceDataChangedEventArgs> DataChanged;