MvtGeometry

Convert the raw MVT command stream of an MvtFeature into lat/lon geometry for a slippy tile at (z, x, y) with the given extent (tile-coordinate resolution; conventionally 4096).

Command stream layout (vector-tile-spec §4.3.2): CommandInteger = (id & 0x7) | (count << 3) id 1 = MoveTo (count×{dx, dy}) id 2 = LineTo (count×{dx, dy}) id 7 = ClosePath (no parameters) Parameter values are zigzag-encoded varints; MvtDecoder left them as raw uint32 bits.

Per geometry type: POINT — one MoveTo with N≥1 parameter pairs, each an independent point. LINESTRING — repeated MoveTo(1) + LineTo(K); each MoveTo starts a new linestring. POLYGON — repeated MoveTo(1) + LineTo(K) + ClosePath; signed area in tile-space discriminates exterior (positive) from interior (negative) rings. Holes follow their enclosing exterior in the stream.

The cursor starts at (0, 0) and accumulates deltas across all commands; MoveTo updates it just like LineTo (the spec is explicit on this).

All entry points are stateless — concurrent calls from parallel tile-fetch coroutines are safe.

Types

Link copied to clipboard
data class LineLabelAnchor(val position: Position, val bearingDeg: Double)

Result of labelAnchorForLine: where to place a line label and how to orient it. bearingDeg is the local tangent bearing in degrees (0 = north, 90 = east), suitable for earth.worldwind.shape.Label.rotation with rotationMode = RELATIVE_TO_GLOBE.

Link copied to clipboard
class PolygonRings(val outer: DoubleArray)

Rings as flat interleaved [lon°, lat°, …] degree arrays — avoids a Position object per vertex (thousands per dense tile) and feeds earcut / MvtBatchedPolygonTile directly.

Link copied to clipboard
class Scratch

Per-tile reused scratch for the decode hot path. One instance per tile (decoded on a single worker thread), threaded through the decode entry points so the inner loops allocate nothing per feature or per ring. NOT thread-safe — one instance per concurrent tile assembly.

Functions

Link copied to clipboard
fun decodeLines(feature: MvtFeature, z: Int, x: Int, y: Int, extent: Int, simplify: Boolean = true, scratch: MvtGeometry.Scratch): List<DoubleArray>

Inflate a LINESTRING feature into polylines (each MoveTo starts a new one), each a flat interleaved [lon°, lat°, …] degree array — no per-vertex Position; altitude dropped.

Link copied to clipboard
fun decodePoints(feature: MvtFeature, z: Int, x: Int, y: Int, extent: Int, scratch: MvtGeometry.Scratch): List<Position>

Inflate a POINT feature's geometry into one Position per point. Empty on malformed input.

Link copied to clipboard
fun decodePolygons(feature: MvtFeature, z: Int, x: Int, y: Int, extent: Int, simplify: Boolean = true, scratch: MvtGeometry.Scratch): List<MvtGeometry.PolygonRings>

Inflate a POLYGON feature into a list of (outerRing, holes) pairs. Exterior rings have positive signed area in tile-space coordinates (where Y grows downward); negative-area rings are holes attached to the most recently emitted exterior ring.

Link copied to clipboard

Find the midpoint of line (by cumulative chord length) and the bearing of the segment containing it. Used by MvtVectorLayer to place single labels along LINESTRING features under MvtStyleRule.LabelPlacement.LINE.

Link copied to clipboard
fun unproject(z: Int, x: Int, y: Int, extent: Int, px: Int, py: Int): Position

Convert a tile-local point at zoom z, tile column x, tile row y, and extent extent (almost always 4096) into a sea-level Position.