WmsRasterTileSource¶
Namespace: ThinkGeo.Core
Serves a WMS service as an RasterTileSource: tiles for a renderer that draws them itself, with no styles and no drawing surface.
public class WmsRasterTileSource : RasterTileSource, System.IDisposable
Inheritance object → RasterTileSource → WmsRasterTileSource
Implements IDisposable
Remarks:
WMS has no tile grid of its own - it answers a GetMap request for any bounding box - so this source supplies the grid: the standard web-mercator matrix set, one GetMap request per tile, built by a WmsClient - the protocol with no Layer around it. The requests are made in EPSG:3857 to match the grid; a server that cannot answer 3857 belongs on the classic reprojection path, not here.
Properties¶
TileSize¶
public int TileSize { get; }
Property Value¶
Client¶
Gets the client this source asks the server through - the place to set the layers, styles, image format and the rest of what WMS understands.
public WmsClient Client { get; }
Property Value¶
DrawingMarginInPixel¶
Ground asked of the server past each side of a tile, in pixels, discarded before the tile is returned. 50 by default - the same name and the same default as WmsAsyncLayer.DrawingMarginInPixel, which answers this on the classic path.
public float DrawingMarginInPixel { get; set; }
Property Value¶
Remarks:
A WMS draws only what is inside the rectangle it is given, and a symbol or label belongs to a point that falls in exactly one tile. So the tile owning that point had the symbol cut flat at its own edge, and the neighbour, owning nothing, drew none of it: a dot sliced vertically down the seam, a label ending mid-digit. Asking for a little more ground than the tile and keeping only the tile moves that cut outside the tile, and the neighbour - margined too - draws the half this one discards. The cost is real and paid per tile: on a 256 pixel tile a 50 pixel margin asks the server for 356 by 356, about 1.9 times the pixels, and the surplus must be decoded and cropped away. 0 restores the tile-exact request and hands back the server bytes untouched. Ink reaching further than the margin is still lost. https://community.thinkgeo.com/t/some-highlights-disappear-when-zooming-in/12475
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 this source's grid, so one cache belongs to one request configuration: a source with other LAYERS, STYLES or another format needs its own cache id. A request that fails is not cached. https://community.thinkgeo.com/t/wmsrastertilesource-wmtsrastertilesource-and-authentication/12470
public RasterTileCache TileCache { get; set; }
Property Value¶
WebProxy¶
Gets or sets the proxy applied to tile requests.
public IWebProxy WebProxy { get; set; }
Property Value¶
TimeoutInSeconds¶
Gets or sets the request timeout, in seconds. Applied when the source opens.
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¶
WmsRasterTileSource(Uri)¶
Initializes a new instance against the given WMS server, with the defaults.
public WmsRasterTileSource(Uri serverUri)
Parameters¶
serverUri Uri
The address of the WMS service.
Remarks:
Use WmsRasterTileSource.WmsRasterTileSource(Uri) to say which layers and styles to ask for, what image format to take them in, or anything else the protocol offers.
WmsRasterTileSource(WmsClient)¶
Initializes a new instance over a WmsClient the caller has configured.
public WmsRasterTileSource(WmsClient client)
Parameters¶
client WmsClient
The configured client. Its ,
, ,
, proxy, timeout and user agent are all used as
they are. The client stays the caller's object; this source does not dispose it.
Exceptions¶
ArgumentNullException
is null.
Remarks:
Everything the protocol can be told is already on WmsClient, typed and validated there; before this constructor existed the only way in was the untyped WmsClient.Parameters dictionary. https://community.thinkgeo.com/t/wms-wfs-feedback-wishes/12476
WmsRasterTileSource(WmsClient, TileMatrixSet)¶
Initializes a new instance that publishes on a grid of the caller's choosing - the one the map is cut on - rather than on web mercator.
public WmsRasterTileSource(WmsClient client, TileMatrixSet tileMatrixSet)
Parameters¶
client WmsClient
The configured client, as above.
tileMatrixSet TileMatrixSet
The grid to publish on, taken as it is: its root, its levels and its tile size in
pixels all become this source's. Hand over the one the map is already cut on -
FeatureSourceVectorTileSource.TileMatrixSet - and the two cannot disagree.
Remarks:
A WMS answers any bounding box, so unlike every other raster source here it has no grid of its own: the one it publishes on is a free choice, and this is where the choice is made. RasterTileSource.ReprojectOnto(TileMatrixSet) is for a source that has tiles to move off one grid onto another, which is why it refuses this class.
When WmsClient.Crs is another system than the grid states, the server's images are warped onto the grid; when they agree - a map and a server both in EPSG:25832 - the GetMap request is made on the grid's own ground and nothing is warped. A grid that states no system is taken to be in the server's.
https://community.thinkgeo.com/t/wms-wfs-feedback-wishes/12476
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 resources this source holds.
protected void Dispose(bool disposing)
Parameters¶
disposing bool
true when called from .
Returns¶
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;