Table of Contents

Class VectorTileSource

Namespace
LansMap.Core.Vector

A provider-agnostic description of where vector (MVT) tiles come from: the per-tile URL template, the provider's zoom limits, the mandatory attribution and the schema's place-layer name.

public sealed class VectorTileSource
Inheritance
object
VectorTileSource

Remarks

Not a TileSource variant. TileSource is raster-shaped (a pixel TileSizePx that has no vector meaning, and a constructor that requires a per-tile URL template that PMTiles cannot supply); bending it to cover both would make one of its members lie for every construction of the other kind.

PMTiles' one-file-plus-byte-range addressing is out of scope: there is no fetch path in this tree that can serve it, so this type carries no field for it. Only the per-tile {z}/{x}/{y} template addressing mode exists here.

Constructors

VectorTileSource(string, string, string, string, int, string, string[], int, int, string, string[])

Creates a validated vector tile source.

public VectorTileSource(string name, string urlTemplate, string attribution, string placeLayerName, int maxConcurrentRequests = 14, string apiKey = null, string[] subdomains = null, int minZoom = 0, int maxNativeZoom = 22, string attributionUrl = null, string[] placeNameKeys = null)

Parameters

name string

Provider name for logs. Required.

urlTemplate string

Per-tile URL template. Must contain {z}, {x} and {y}.

attribution string

Credit text. Required.

placeLayerName string

MVT layer name for place features. Required.

maxConcurrentRequests int

Requests in flight at once, 1 to 32. Omit it for DefaultMaxConcurrentRequests.

apiKey string

Key substituted for {key}; may be null or omitted when the template has no {key}.

subdomains string[]

Hostnames rotated through {s}; may be null when the template has no {s}.

minZoom int

Shallowest level served, 0 to 24.

maxNativeZoom int

Deepest level served, from minZoom to 24.

attributionUrl string

Link target for the credit; null for no link.

placeNameKeys string[]

Priority-ordered name-tag keys; null uses DefaultPlaceNameKeys. If given, must be non-empty; cloned so later mutation of the caller's array cannot reach this instance.

Exceptions

ArgumentException

The name, template, attribution or layer name is missing; the template lacks a required placeholder; it uses {key} or {s} without the matching value; placeNameKeys is empty; or a zoom/concurrency value is out of range.

Fields

DefaultMaxConcurrentRequests

Concurrency used when a source does not name one: same default as DefaultMaxConcurrentRequests.

public const int DefaultMaxConcurrentRequests = 14

Field Value

int

Properties

ApiKey

API key substituted for {key}. Empty string, never null, when the provider needs no key.

public string ApiKey { get; }

Property Value

string

Attribution

Credit text, rendered verbatim by the attribution overlay. Never empty; the constructor rejects a source without it.

public string Attribution { get; }

Property Value

string

AttributionUrl

Where the attribution text links to. Empty string, never null.

public string AttributionUrl { get; }

Property Value

string

CacheTag

Provider identity for the disk cache: an FNV-1a 64 hash of a "vector:"-tagged URL template, same scheme as CacheTag (which tags its own hash "raster:") so the two source kinds never tag identically on an identical template.

public ulong CacheTag { get; }

Property Value

ulong

DefaultPlaceNameKeys

Default name-tag priority: Latin-capable name preferred because the glyph layer renders a Latin bitmap font. Exposed only as a ReadOnlySpan<T> (see PlaceNameKeys for why) - the backing array is private so nothing outside this type can ever hold a mutable reference to it.

public static ReadOnlySpan<string> DefaultPlaceNameKeys { get; }

Property Value

ReadOnlySpan<string>

MaxConcurrentRequests

How many requests to keep in flight against this provider at once, 1 to 32.

public int MaxConcurrentRequests { get; }

Property Value

int

MaxNativeZoom

Deepest zoom level the provider actually serves tiles at.

public int MaxNativeZoom { get; }

Property Value

int

MinZoom

Shallowest zoom level the provider serves, 0 for world-wide.

public int MinZoom { get; }

Property Value

int

Name

Human-readable provider name, used in logs. Never empty.

public string Name { get; }

Property Value

string

PlaceLayerName

MVT layer name carrying point-of-interest / place features for this schema, for example "place". Passed to Parse(byte[], TileCoord, string, ReadOnlySpan<string>, List<MvtPlace>) instead of a hardcoded literal so a later schema can supply a different layer name without changing the parser.

public string PlaceLayerName { get; }

Property Value

string

PlaceNameKeys

Priority-ordered name-tag keys for this schema: the first key in the array that a feature carries wins. Passed to Parse(byte[], TileCoord, string, ReadOnlySpan<string>, List<MvtPlace>) instead of a hardcoded static so a schema with different name keys needs no parser change. Defaults to DefaultPlaceNameKeys when the constructor is not given one. Never null or empty.

public ReadOnlySpan<string> PlaceNameKeys { get; }

Property Value

ReadOnlySpan<string>

Remarks

Returns a ReadOnlySpan<T> over this instance's private backing array rather than the array itself, so callers cannot mutate the stored keys through the getter. Custom keys are cloned once in the constructor; the default keys share a private backing array that is never exposed as a mutable string[].

Subdomains

Subdomains rotated through {s}. Empty array, never null, when the template uses no {s}.

public string[] Subdomains { get; }

Property Value

string[]

UrlTemplate

The per-tile URL template, with {z}, {x}, {y} and optionally {key} and {s} left unexpanded. Always present: the archive-addressed (PMTiles) mode is out of scope for this type, so there is no optional-template constructor path.

public string UrlTemplate { get; }

Property Value

string

Methods

Build(TileCoord)

Builds the URL for one tile. Same zero-GC shape as Build(TileCoord): one string per call, formatted into a pooled buffer first, so repeated calls allocate only the returned string.

public string Build(TileCoord tile)

Parameters

tile TileCoord

Tile whose {z}, {x}, {y} (and {s} if used) are substituted.

Returns

string

The expanded URL string.

DiskCacheKey(TileCoord)

Disk-cache key for one tile from this source: CacheTag XOR the packed tile key times a mixing constant. Same scheme as DiskCacheKey(TileCoord), kept independent because the two source types are deliberately not related by inheritance.

public ulong DiskCacheKey(TileCoord tile)

Parameters

tile TileCoord

Tile whose packed key is mixed in.

Returns

ulong

64-bit cache key, distinct from a raster source with the same template.