Class VectorTileSource
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
-
objectVectorTileSource
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
namestringProvider name for logs. Required.
urlTemplatestringPer-tile URL template. Must contain
{z},{x}and{y}.attributionstringCredit text. Required.
placeLayerNamestringMVT layer name for place features. Required.
maxConcurrentRequestsintRequests in flight at once, 1 to 32. Omit it for DefaultMaxConcurrentRequests.
apiKeystringKey substituted for
{key}; may be null or omitted when the template has no{key}.subdomainsstring[]Hostnames rotated through
{s}; may be null when the template has no{s}.minZoomintShallowest level served, 0 to 24.
maxNativeZoomintDeepest level served, from
minZoomto 24.attributionUrlstringLink target for the credit; null for no link.
placeNameKeysstring[]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;placeNameKeysis 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
Properties
ApiKey
API key substituted for {key}. Empty string, never null,
when the provider needs no key.
public string ApiKey { get; }
Property Value
Attribution
Credit text, rendered verbatim by the attribution overlay. Never empty; the constructor rejects a source without it.
public string Attribution { get; }
Property Value
AttributionUrl
Where the attribution text links to. Empty string, never null.
public string AttributionUrl { get; }
Property Value
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
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
MaxConcurrentRequests
How many requests to keep in flight against this provider at once, 1 to 32.
public int MaxConcurrentRequests { get; }
Property Value
MaxNativeZoom
Deepest zoom level the provider actually serves tiles at.
public int MaxNativeZoom { get; }
Property Value
MinZoom
Shallowest zoom level the provider serves, 0 for world-wide.
public int MinZoom { get; }
Property Value
Name
Human-readable provider name, used in logs. Never empty.
public string Name { get; }
Property Value
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
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
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
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
tileTileCoordTile 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
tileTileCoordTile whose packed key is mixed in.
Returns
- ulong
64-bit cache key, distinct from a raster source with the same template.