Table of Contents

Class MvtGeometry

Namespace
SpatialNET.IO
Assembly
SpatialNET.IO.dll

The MVT geometry encoding (spec section 4.3): command integers (id & 0x7) | (count << 3) with MoveTo = 1, LineTo = 2 and ClosePath = 7, followed by zigzag-encoded coordinate deltas relative to a cursor that persists across the parts of a feature.

public static class MvtGeometry

Inheritance

Inherited Members

Fields

ClosePath

The ClosePath command id.

public const int ClosePath = 7

Field Value

int

LineTo

The LineTo command id.

public const int LineTo = 2

Field Value

int

MoveTo

The MoveTo command id.

public const int MoveTo = 1

Field Value

int

Methods

Command(int, int)

A command integer.

public static uint Command(int id, int count)

Parameters

id int

The command id: SpatialNET.IO.MvtGeometry.MoveTo, SpatialNET.IO.MvtGeometry.LineTo or SpatialNET.IO.MvtGeometry.ClosePath.

count int

The repeat count, 0 ≤ count < 2^29.

Returns

uint

Exceptions

ArgumentOutOfRangeException

count is out of range.

Decode(MvtGeometryType, IReadOnlyList<uint>, IGeometryFactory?, MvtTileTransform?)

Decodes command integers into a geometry (see SpatialNET.IO.MvtFeature.ToGeometry(SpatialNET.IGeometryFactory,SpatialNET.IO.MvtTileTransform)). Polygon rings are classified by the sign of their area in tile coordinates (positive = exterior); a ring with zero area is dropped, an interior ring before any exterior ring is read as an exterior ring (lenient towards version 1 tiles).

public static IGeometry2D Decode(MvtGeometryType type, IReadOnlyList<uint> commands, IGeometryFactory? factory = null, MvtTileTransform? transform = null)

Parameters

type MvtGeometryType

The geometry type.

commands IReadOnlyList<uint>

The command integers.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

transform MvtTileTransform?

If given, coordinates are converted from tile to world coordinates.

Returns

IGeometry2D

Exceptions

ArgumentNullException

commands is null.

FormatException

The commands are invalid for the type, or the type is SpatialNET.IO.MvtGeometryType.Unknown.

InvalidOperationException

No factory available.

Encode(IGeometry2D)

Encodes a geometry that is in tile coordinates (see SpatialNET.IO.MvtFeature.Create(SpatialNET.IGeometry2D,System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.Object}},System.Nullable{System.UInt64}) for the rounding and cleaning rules).

public static (MvtGeometryType Type, uint[] Commands) Encode(IGeometry2D tileGeometry)

Parameters

tileGeometry IGeometry2D

The geometry in tile coordinates.

Returns

(MvtGeometryType Type, uint[] Commands)

The geometry type and the command integers; SpatialNET.IO.MvtGeometryType.Unknown and none if nothing is left.

Exceptions

ArgumentNullException

tileGeometry is null.

ArgumentException

A coordinate is not finite or outside ±2^30.

UnZigZag(uint)

The inverse of SpatialNET.IO.MvtGeometry.ZigZag(System.Int32).

public static int UnZigZag(uint value)

Parameters

value uint

The encoded value.

Returns

int

ZigZag(int)

The zigzag encoding of a parameter integer: (n << 1) ^ (n >> 31).

public static uint ZigZag(int value)

Parameters

value int

The value.

Returns

uint