Skip to content

TgTilesVectorTileSource

Namespace: ThinkGeo.Core

A local .tgtiles archive of vector tiles - tiles pre-cut on a projected grid of their own by VectorTgTilesGenerator - read on the grid the file itself names. It reads a plain .pmtiles as well, on Web Mercator, so it is a strict superset of PmTilesVectorTileSource. The archive is the data; how it draws comes from the style layers that reference it.

public sealed class TgTilesVectorTileSource : IVectorTileSource, IRawVectorTileSource, System.IDisposable

Inheritance object → TgTilesVectorTileSource
Implements IVectorTileSource, IRawVectorTileSource, IDisposable

Remarks:

The caller passes no grid. The archive carries the grid it was cut on and this source publishes it as TgTilesVectorTileSource.TileMatrixSet, so a map given this source draws on that grid - the way it does for a FeatureSourceVectorTileSource built on one, camera ladder and all. A grid supplied from outside would sooner or later be the un-squared data extent the archive's own root was grown from, and every tile would be off by the margin; so there is no way to supply one.

The decision is by content, never by extension: an archive without the grid key is a plain PMTiles archive and is read on Web Mercator whatever it is called, and one with the key is read on its grid even when named .pmtiles. The keys are described on ; is what they say the grid is in.

.tgtiles is a ThinkGeo format. Byte for byte it is a PMTiles v3 archive, which is why other tools open it - and place every tile in the wrong spot without an error, because PMTiles has no way to say its tiles are not on Web Mercator. The extension is the warning; keep it.

https://community.thinkgeo.com/t/wms-wfs-feedback-wishes/12476

Properties

SourceId

Gets or sets the id style layers reference this source by (their "source"). Binding a style document to this source sets it to the document's source name.

public string SourceId { get; set; }

Property Value

string

MetadataJson

The archive's metadata JSON, grid keys included.

public string MetadataJson { get; }

Property Value

string

TileMatrixSet

Gets the grid the tiles are cut on, read from the archive: its own for a .tgtiles, Web Mercator for a plain .pmtiles. A map given this source draws on it. A .tgtiles grid carries the coordinate system the archive declares in its TileMatrixSet.Projection - the proj definition is authoritative and the SRID is 0 for a custom projection - which is what to build a ProjectionConverter from when mixing the archive with other data.

public TileMatrixSet TileMatrixSet { get; }

Property Value

TileMatrixSet

MinDataZoom

public int MinDataZoom { get; }

Property Value

int

MaxDataZoom

public int MaxDataZoom { get; }

Property Value

int

IsOpen

public bool IsOpen { get; }

Property Value

bool

Constructors

TgTilesVectorTileSource(string)

Initializes a source over the specified archive - a .tgtiles, or a plain .pmtiles.

public TgTilesVectorTileSource(string filePath)

Parameters

filePath string
The path of the archive.

Methods

OpenAsync(CancellationToken)

public Task OpenAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

GetBoundingBox()

Returns the archive's declared coverage in the grid's own coordinates - the container header's longitude/latitude bounds converted through - or the whole grid when the archive declares no bounds or no coordinate system.

public RectangleShape GetBoundingBox()

Returns

RectangleShape

GetFeaturesFromTileAsync(int, long, long, CancellationToken)

public Task<Dictionary<string, Collection<Feature>>> GetFeaturesFromTileAsync(int zoom, long x, long y, CancellationToken cancellationToken)

Parameters

zoom int

x long

y long

cancellationToken CancellationToken

Returns

Task<Dictionary<string, Collection<Feature>>>

Dispose()

Closes the archive.

public void Dispose()

Returns

void