mlt

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package mlt reads and writes MapLibre Tiles (https://github.com/maplibre/maplibre-tile-spec). Only the stable v1 layer format is supported

Index

Constants

This section is empty.

Variables

View Source
var ErrMalformed = errors.New("malformed MLT tile")

Wrapped by every error caused by a tile that doesn't follow the specification

View Source
var ErrUnsupported = errors.New("unsupported MLT content")

Wrapped by errors for valid tile content this package can't process

Functions

func Encode

func Encode(layers []Layer) ([]byte, error)

Writes a v1 tile using only the simplest encodings, favoring compatibility with every decoder over size

Types

type Column

type Column struct {
	Type     ColumnType
	Name     string
	Nullable bool   // Some features may lack a value
	Present  []bool // Only set when Nullable
	// Per feature slice of the Go type matching Type. Zero where absent, nil for SharedDict
	Values any
	// ColumnSharedDict only. Columns sharing one dictionary, named by appending their Name to the parent's
	Children []Column
}

type ColumnType

type ColumnType uint8

Without the nullable flag

const (
	ColumnBool       ColumnType = 10
	ColumnInt32      ColumnType = 16
	ColumnUint32     ColumnType = 18
	ColumnInt64      ColumnType = 20
	ColumnUint64     ColumnType = 22
	ColumnFloat      ColumnType = 24
	ColumnDouble     ColumnType = 26
	ColumnString     ColumnType = 28
	ColumnSharedDict ColumnType = 30
)

type IDColumn

type IDColumn struct {
	Long     bool     // Encoded as 64 bit rather than 32 bit ids
	Nullable bool     // Some features may lack an id
	Present  []bool   // Only set when Nullable
	Values   []uint64 // Zero where not present
}

type Layer

type Layer struct {
	Name       string
	Extent     uint32
	ID         *IDColumn      // Nil if the layer has no id column
	Geometries []orb.Geometry // In tile coordinates. Polygon rings are closed
	Columns    []Column
}

Every per-feature slice is indexed by feature

func Decode

func Decode(data []byte) ([]Layer, int, error)

Parses every v1 layer. Other formats or layers past maxTileBytes are skipped and counted. Features past maxFeatureBytes are dropped

func (Layer) Clip

func (l Layer) Clip(b orb.Bound) Layer

Trims every geometry to a bound in tile coordinates, dropping features left empty

func (Layer) FeatureCount

func (l Layer) FeatureCount() int

func (Layer) Select

func (l Layer) Select(keep []int) Layer

Keeps only the features at the given indexes, in the order given

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL