RasterTileSource¶
Namespace: ThinkGeo.Core
Supplies encoded raster tiles to a renderer that draws them itself, addressed by z/x/y on a tile grid.
public abstract class RasterTileSource : System.IDisposable
Inheritance object → RasterTileSource
Implements IDisposable
Remarks:
This level is the ADDRESSING and the reprojection; where the bytes come from belongs to the subclass, which implements - HTTP in XyzRasterTileSource, SQLite in MbTilesRasterTileSource, a file in PmTilesRasterTileSource, a service in WmtsRasterTileSource.
Tiles are handed over encoded (PNG, JPEG, WebP - whatever the server sent) rather than decoded. Decoding is the renderer's business: it knows which thread may touch the GPU and what pixel format it wants to upload.
Caching deliberately does NOT live here, which is where this differs from the classic RasterXyzTileAsyncLayer. A tile cache earns its keep against a network; against a local archive it is a second copy of a file already on disk, and a local source that inherited TileCache, ProjectedTileCache and IsCacheOnly would be answering questions that do not apply to it. So the cache sits on the web source.
Properties¶
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
TileSize¶
Gets the edge length, in pixels, of the tiles this source publishes.
public int TileSize { get; }
Property Value¶
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; private set; }
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; private set; }
Property Value¶
IsOpen¶
Gets a value indicating whether the source has been opened.
public abstract bool IsOpen { get; }
Property Value¶
Methods¶
A(TileMatrixSet)¶
internal static Projection A(TileMatrixSet )
Parameters¶
Returns¶
A(Projection, Projection)¶
internal static bool A(Projection , Projection )
Parameters¶
`` Projection
`` Projection
Returns¶
A(int)¶
internal static bool A(int )
Parameters¶
`` int
Returns¶
ReprojectOnto(TileMatrixSet)¶
Publishes this source's tiles on another grid - the map's own, most often - warping each tile from this source's coordinate system into that grid's. Both grids say which system they are in, so nothing else is needed: a national XYZ or WMTS service goes onto web mercator, a mercator basemap onto a projected map's grid.
public void ReprojectOnto(TileMatrixSet tileMatrixSet)
Parameters¶
tileMatrixSet TileMatrixSet
The grid to publish on, taken as it is: its root, its levels, its tile size in pixels
and its coordinate system all become this source's. Hand over the one the map is
already cut on - FeatureSourceVectorTileSource.TileMatrixSet - and the two
cannot disagree.
Returns¶
Exceptions¶
ArgumentException
The grid states no coordinate system, has no levels or no area, or its root is not square.
InvalidOperationException
The source fetches the exact ground each tile needs, a WMS, and has no grid of its own to move.
Remarks:
The grid must say which coordinate system it is in - built by TileMatrixSet.CreateTileMatrixSet(int, RectangleShape, GeographyUnit, int), or the web-mercator pyramid, which is recognised. So must this source's own grid; a source that learns its grid when it opens is checked then.
The grid is used exactly as given and never adjusted, because it is somebody else's: a root that is not square is refused rather than grown, since growing it would move this source off the tiles the map asks for. State ground rather than a grid - new FeatureSourceVectorTileSource(dataExtent, projection) - and the squaring is done there, once, for both, with the system stated.
Each tile costs one mosaic of the native tiles under it and one resampling, done by the SDK's own projection engine - the one the map's vectors are converted with, so the two land together.
Refresh(RectangleShape)¶
Announces that the tiles have changed, so a map drawing them redraws.
public void Refresh(RectangleShape extent)
Parameters¶
extent RectangleShape
The ground that changed, or null for all of it.
Returns¶
OpenAsync(CancellationToken)¶
Prepares the source for tile requests. The map opens the sources its style names itself, so an application calls this only to read something - the bounding box, the zoom range - before the map does.
public abstract Task OpenAsync(CancellationToken cancellationToken)
Parameters¶
cancellationToken CancellationToken
A cancellation token.
Returns¶
GetTileImageAsync(int, long, long, CancellationToken)¶
The encoded bytes of one tile of RasterTileSource.TileMatrixSet, warped from this source's own grid when the tiles are being republished onto another grid, and served as they come when they are not.
public Task<Byte[]> GetTileImageAsync(int zoom, long x, long y, CancellationToken cancellationToken)
Parameters¶
zoom int
The tile zoom level.
x long
The tile column.
y long
The tile row.
cancellationToken CancellationToken
A cancellation token.
Returns¶
Task<Byte[]>
The tile's bytes, or null where the source has no tile.
GetTileImageAsyncCore(int, long, long, CancellationToken)¶
The encoded bytes of one tile of - where this source's bytes actually come from.
protected abstract Task<Byte[]> GetTileImageAsyncCore(int zoom, long x, long y, CancellationToken cancellationToken)
Parameters¶
zoom int
The tile zoom level, on the native grid.
x long
The tile column, on the native grid.
y long
The tile row, on the native grid.
cancellationToken CancellationToken
A cancellation token.
Returns¶
Task<Byte[]>
The tile's bytes, or null where the source has no tile.
SetDataZoomRange(int, int)¶
Clamps a range read from the data into the pyramid and records it. Kept here because every subclass that reads a declared range has the same two mistakes available: a floor above its own ceiling, and a ceiling past the end of the matrix set.
protected void SetDataZoomRange(int minDataZoom, int maxDataZoom)
Parameters¶
minDataZoom int
The shallowest level the data declares.
maxDataZoom int
The deepest level the data declares.
Returns¶
Dispose()¶
Releases what the source holds - an HTTP client, an open archive, a decoded image. A source given to a map is the map's to dispose for as long as the map holds it: the map disposes every source it still has when it is itself disposed, and disposes nothing a restyle drops - a source that SetStyleAsync replaced is yours to dispose once the new style is applied.
public void Dispose()
Returns¶
Dispose(bool)¶
Releases the resources this source holds; the base class holds none.
protected void Dispose(bool disposing)
Parameters¶
disposing bool
True when called from .
Returns¶
Events¶
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;