Table of Contents

Class MvtFeature

Namespace
SpatialNET.IO
Assembly
SpatialNET.IO.dll

A feature of a vector tile layer: optional id, geometry type, the geometry as MVT command integers in tile coordinates and the attributes. Build it from a tile-coordinate geometry with SpatialNET.IO.MvtFeature.Create(SpatialNET.IGeometry2D,System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.Object}},System.Nullable{System.UInt64}) or let SpatialNET.IO.MvtTileBuilder do the transform from world coordinates.

public sealed class MvtFeature

Inheritance

Inherited Members

Properties

Attributes

The attributes in order; keys and values are deduplicated per layer on encoding.

public IReadOnlyList<KeyValuePair<string, MvtValue>> Attributes { get; init; }

Property Value

IReadOnlyList<KeyValuePair<string, MvtValue>>

Geometry

The geometry as command integers (MoveTo/LineTo/ClosePath with zigzag-encoded deltas), see SpatialNET.IO.MvtGeometry.

public IReadOnlyList<uint> Geometry { get; init; }

Property Value

IReadOnlyList<uint>

GeometryType

The geometry type.

public MvtGeometryType GeometryType { get; init; }

Property Value

MvtGeometryType

Id

The feature id (id, field 1); null = not written. Hosts typically use the object id.

public ulong? Id { get; init; }

Property Value

ulong?

Methods

Create(IGeometry2D, IEnumerable<KeyValuePair<string, object?>>?, ulong?)

Creates a feature from a geometry that is already in tile coordinates (y down, 0..extent): coordinates are rounded to integers, repeated points and degenerate parts dropped and polygon rings oriented as MVT requires.

public static MvtFeature? Create(IGeometry2D tileGeometry, IEnumerable<KeyValuePair<string, object?>>? attributes = null, ulong? id = null)

Parameters

tileGeometry IGeometry2D

The geometry in tile coordinates.

attributes IEnumerable<KeyValuePair<string, object?>>?

The attributes; null values are skipped (MVT has no null), a repeated key keeps its first value.

id ulong?

The feature id or null.

Returns

MvtFeature?

The feature, or null if nothing is left of the geometry.

Exceptions

ArgumentNullException

tileGeometry is null.

ArgumentException

A coordinate is not finite or outside the 32-bit range.

ToGeometry(IGeometryFactory?, MvtTileTransform?)

Decodes the geometry: points → SpatialNET.IPoint2D (one) or SpatialNET.IMultiPoint2D, lines → SpatialNET.IPolyline2D, polygons → SpatialNET.IPolygon2D (exterior rings by positive area in tile coordinates, interior rings by negative area).

public IGeometry2D ToGeometry(IGeometryFactory? factory = null, MvtTileTransform? transform = null)

Parameters

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

transform MvtTileTransform?

If given, coordinates are converted from tile to world coordinates; otherwise they stay tile coordinates.

Returns

IGeometry2D

Exceptions

FormatException

The command integers are invalid or the geometry type is SpatialNET.IO.MvtGeometryType.Unknown.

InvalidOperationException

No factory available.