GeoImageRasterTileSource¶
Namespace: ThinkGeo.Core
Serves one georeferenced bitmap - a radar composite, a weather graphic, a scanned chart - as raster tiles. This is the source behind a style's "type": "image" declaration, and it can equally be built in code and handed to MapStyle.AddRaster(RasterTileSource, Nullable<RasterPaint>, string, StyleLayerSlot), which is how an application drapes its own image over the map.
public class GeoImageRasterTileSource : RasterTileSource, System.IDisposable
Inheritance object → RasterTileSource → GeoImageRasterTileSource
Implements IDisposable
Remarks:
The image anchors to an axis-aligned extent in its own coordinate system. In the system of the grid it publishes on - web mercator unless a grid is given - it is cut straight into tiles; in any other - WGS84 degrees, the shape most published weather imagery arrives in, a UTM zone, a national grid - each tile is warped out of it by the SDK's projection engine, so it lands where the map's vectors do.
GeoImageRasterTileSource.Update(Byte[]) swaps the bitmap and keeps the placement - an animation loop is one Update per frame plus a RefreshRasterTiles on the map, no style change and no recompile.
Properties¶
TileSize¶
public int TileSize { get; }
Property Value¶
TransparentColor¶
Gets or sets the colour that reads as "no data": pixels exactly this colour become transparent when the image is decoded (at open, and on every GeoImageRasterTileSource.Update(Byte[])). Published composites often ship on an opaque solid background - the NEXRAD mosaics are black-backed palette PNGs - and without this the whole footprint drapes as a dark rectangle.
public GeoColor TransparentColor { 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¶
GeoImageRasterTileSource(Byte[], RectangleShape, Projection, TileMatrixSet)¶
Initializes a new instance over image bytes the application already holds (any format SkiaSharp decodes - PNG, JPEG, WebP, BMP).
public GeoImageRasterTileSource(Byte[] imageBytes, RectangleShape extent, Projection sourceProjection, TileMatrixSet tileMatrixSet)
Parameters¶
imageBytes Byte[]
The encoded image.
extent RectangleShape
Where the image lies, in . The image's top row lies on the extent's north edge.
sourceProjection Projection
The image's coordinate system: null for the system of the grid it publishes on. An image in that system is cut straight into tiles, one in any other is warped onto the grid tile by tile.
tileMatrixSet TileMatrixSet
The grid to publish on, or null for web mercator. A grid is 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:
Like a WMS and the classic raster source, this one has no grid of its own: it can serve whatever ground a tile covers, so the grid it publishes on is a free choice. https://community.thinkgeo.com/t/wms-wfs-feedback-wishes/12476
Methods¶
FromUri(string, RectangleShape, Projection, TileMatrixSet)¶
A source over an image at a URL or local file path, fetched when the source opens. The image lies on in - null for the grid's own system - and is warped onto , or web mercator, when the two differ.
public static GeoImageRasterTileSource FromUri(string uriOrPath, RectangleShape extent, Projection sourceProjection, TileMatrixSet tileMatrixSet)
Parameters¶
uriOrPath string
extent RectangleShape
sourceProjection Projection
tileMatrixSet TileMatrixSet
Returns¶
Update(Byte[])¶
Replaces the image and keeps the placement. Cut tiles are dropped and RasterTileSource.Refresh(RectangleShape) is raised, so every map drawing the source refetches and shows the new frame by itself. The new image may have different pixel dimensions.
public void Update(Byte[] imageBytes)
Parameters¶
imageBytes Byte[]
Returns¶
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 held by this source.
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;