Skip to content

ClassicRasterTileSource

Namespace: ThinkGeo.Core

Serves any classic RasterSource - a GDAL-backed ECW, MrSID or GeoTIFF, Core's own readers, an application's custom source - as raster tiles for the GPU renderer. Each tile is one RasterSource.GetImage(RectangleShape, int, int) call, so whatever windowed reading and overview selection the source does is what the tiles get.

public class ClassicRasterTileSource : RasterTileSource, System.IDisposable

Inheritance object → RasterTileSource → ClassicRasterTileSource
Implements IDisposable

Remarks:

The source must answer requests in Web Mercator: the tile grid is Web Mercator, and a source that reads its raster's native projection without warping would hand back misplaced ground. There are two ways to have it answer so, and both need the GDAL extension, because warping a raster is GDAL's job in this SDK.

A raster GDAL opens - GeoTIFF, ECW, MrSID, or a PNG / JPEG / BMP beside its world file - is one property: GdalRasterSource.WarpProjection, set to new Projection(3857), which warps through a virtual dataset at open and keeps every read windowed.

Any other RasterSource warps per tile instead: set its RasterSource.ProjectionConverter to a GdalProjectionConverter(sourceSrid, 3857). RasterSource.GetImage(RectangleShape, int, int) hands every image it reads to that converter, and answers in the converted projection, so the tiles cut here line up. The managed ProjectionConverter will not do: it converts extents but throws NotImplementedException for an image, which is the point at which a source in another projection appears to have no way onto the GPU.

Register the result with MapStyle.AddRaster like any other raster source.

Properties

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

ClassicRasterTileSource(RasterSource)

Initializes a new instance over a classic raster source. The source is opened - if it is not already - when this source opens, and closed again on dispose only if it was opened here.

public ClassicRasterTileSource(RasterSource source)

Parameters

source RasterSource
The raster source to serve tiles from. It must answer in Web Mercator.

ClassicRasterTileSource(RasterSource, 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 ClassicRasterTileSource(RasterSource source, TileMatrixSet tileMatrixSet)

Parameters

source RasterSource
The classic raster source read for pixels.

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:

This source asks for whatever ground a tile covers, so like a WMS it has no grid of its own and the one it publishes on is a free choice. Data in another coordinate system is converted ONCE, by the classic source itself: set source.ProjectionConverter = new GdalProjectionConverter(dataSrid, gridSrid) and nothing passes through web mercator on the way. https://community.thinkgeo.com/t/wms-wfs-feedback-wishes/12476

Methods

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 held by this source.

protected void Dispose(bool disposing)

Parameters

disposing bool
True when called from .

Returns

void

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;