Skip to content

WmtsRasterTileSource

Namespace: ThinkGeo.Core

Serves the tiles of a WMTS layer as an RasterTileSource: tiles for a renderer that draws them itself, with no styles and no drawing surface.

public class WmtsRasterTileSource : RasterTileSource, System.IDisposable

Inheritance object → RasterTileSource → WmtsRasterTileSource
Implements IDisposable

Remarks:

Stands on WmtsClient - the WMTS protocol with no Layer around it: capabilities negotiation, tile matrix selection and GetTile URL construction. WmtsRasterTileSource.OpenAsync(CancellationToken) fetches the server's capabilities, after which TileMatrixSet is the grid of the chosen WmtsRasterTileSource.TileMatrixSetName. A renderer that only speaks web mercator (the GPU basemap) needs the server to publish a web-mercator matrix set - many do, commonly named "3857" or "GoogleMapsCompatible".

Properties

ActiveLayerName

Gets or sets the WMTS layer to request tiles from.

public string ActiveLayerName { get; set; }

Property Value

string

ActiveStyleName

Gets or sets the WMTS style to request.

public string ActiveStyleName { get; set; }

Property Value

string

OutputFormat

Gets or sets the image format to request, e.g. "image/png". Left unset, the open picks "image/png" where the layer advertises it and the first format the layer advertises where it does not.

public string OutputFormat { get; set; }

Property Value

string

TileMatrixSetName

Gets or sets which of the server's tile matrix sets to serve tiles on.

public string TileMatrixSetName { get; set; }

Property Value

string

WebProxy

Gets or sets the proxy applied to tile requests.

public IWebProxy WebProxy { get; set; }

Property Value

IWebProxy

Credentials

Gets or sets the credentials a service behind HTTP authentication is answered with, for the capabilities request and every tile.

public ICredentials Credentials { get; set; }

Property Value

ICredentials

TileCache

Where fetched tiles are kept between runs, or null to request every tile every time. The same RasterTileCache the classic layers take - a FileRasterTileCache on disk, an InMemoryRasterTileCache for one session. A tile is keyed by zoom, column and row of the chosen matrix set, so one cache belongs to one layer, style and matrix set: another needs its own cache id. A request that fails is not cached; a tile the service does not have is not either. https://community.thinkgeo.com/t/wmsrastertilesource-wmtsrastertilesource-and-authentication/12470

public RasterTileCache TileCache { get; set; }

Property Value

RasterTileCache

TimeoutInSeconds

Gets or sets the request timeout, in seconds.

public int TimeoutInSeconds { get; set; }

Property Value

int

TileSize

public int TileSize { get; }

Property Value

int

IsOpen

public bool IsOpen { get; }

Property Value

bool

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

TileMatrixSet

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

bool

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

int

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

int

Constructors

WmtsRasterTileSource(Uri)

Initializes a new instance against the given WMTS server.

public WmtsRasterTileSource(Uri serverUri)

Parameters

serverUri Uri

WmtsRasterTileSource(Uri, WmtsServerEncodingType)

Initializes a new instance against the given WMTS server, asking it in the given request encoding. A proxy is WmtsRasterTileSource.WebProxy, as on the other sources.

public WmtsRasterTileSource(Uri serverUri, WmtsServerEncodingType encodingType)

Parameters

serverUri Uri

encodingType WmtsServerEncodingType

Methods

GetBoundingBox()

Gets the extent the chosen layer covers, in the coordinates of the chosen tile matrix set. Valid after WmtsRasterTileSource.OpenAsync(CancellationToken).

public RectangleShape GetBoundingBox()

Returns

RectangleShape

OpenAsync(CancellationToken)

public Task OpenAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

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

Task<Byte[]>

Dispose(bool)

Releases the resources this source holds.

protected void Dispose(bool disposing)

Parameters

disposing bool
true when called from .

Returns

void

Events

SendingHttpRequest

Raised before each request this source sends - the capabilities document when it opens, and every tile after that. Rewrite the request to add an API key, a signed URL or authentication headers; set Cancel to skip it. The same event the classic layers and the XYZ and vector tile sources raise, so a handler written for one of those works here unchanged. https://community.thinkgeo.com/t/wmsrastertilesource-wmtsrastertilesource-and-authentication/12470

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;