mvt

package
v0.0.0-...-1f4f1c7 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Feature fields
	FEATURE_ID_FIELD        byte = 8  // (1 << 3) | 0
	FEATURE_TAGS_FIELD      byte = 18 // (2 << 3) | 2
	FEATURE_GEOM_TYPE_FIELD byte = 24 // (3 << 3) | 0
	FEATURE_GEOMETRY_FIELD  byte = 34 // (4 << 3) | 2

	// Layer fields
	LAYER_VERSION_FIELD  byte = 120 // (15 << 3) | 0
	LAYER_NAME_FIELD     byte = 10  // (1 << 3) | 2
	LAYER_FEATURES_FIELD byte = 18  // (2 << 3) | 2
	LAYER_KEY_FIELD      byte = 26  // (3 << 3) | 2
	LAYER_VALUE_FIELD    byte = 34  // (4 << 3) | 2
	LAYER_EXTENT_FIELD   byte = 40  // (5 << 3) | 0

	// Value fields
	VALUE_STRING_FIELD    byte = 10 // (1 << 3) | 2
	VALUE_FLOAT32_FIELD   byte = 21 // (2 << 3) | 5
	VALUE_FLOAT64_FIELD   byte = 24 // (3 << 3) | 1
	VALUE_INT64_FIELD     byte = 32 // (4 << 3) | 0
	VALUE_UVARINT64_FIELD byte = 40 // (5 << 3) | 0
	VALUE_VARINT64_FIELD  byte = 48 // (6 << 3) | 0
	VALUE_BOOL_FIELD      byte = 56 // (6 << 3) | 0

	// Tile fields
	TILE_LAYERS_FIELD byte = 26 // (3 << 3) | 2
)

Byte identifiers of fields in MVT protobuf These are encoded as: (field ID << 3) | field type see https://developers.google.com/protocol-buffers/docs/encoding

Variables

View Source
var EARTH_RADIUS float64 = 6378137.0
View Source
var RAD2DEG float64 = 180 / math.Pi

Functions

func EncodeBoolValue

func EncodeBoolValue(v bool) []byte

EncodeByteValue encodes a bool as a Value for the MVT protobuf

func EncodeByteValue

func EncodeByteValue(v []byte) []byte

EncodeByteValue encodes a byte slice as a Value for the MVT protobuf

func EncodeBytes

func EncodeBytes(v []byte) []byte

EncodeBytes returns a byte buffer with the a Uvarint of the length of the byte slice followed by the bytes

func EncodeFloat32Value

func EncodeFloat32Value(v float32) []byte

EncodeByteValue encodes a float32 as a Value for the MVT protobuf

func EncodeFloat64Value

func EncodeFloat64Value(v float64) []byte

EncodeByteValue encodes a float36 as a Value for the MVT protobuf

func EncodeInt64Value

func EncodeInt64Value(v int64) []byte

EncodeByteValue encodes a int64 as a Value (of type Varint) for the MVT protobuf

func EncodeKey

func EncodeKey(key string) []byte

EncodeKey returns a buffer representing the key type, followed by the length of the string, followed by the bytes representing the string

func EncodeString

func EncodeString(v string) []byte

EncodeString returns a byte buffer with the a Uvarint of the length of the string followed by the string value

func EncodeStringValue

func EncodeStringValue(v string) []byte

EncodeByteValue encodes a string as a Value for the MVT protobuf

func EncodeUint32

func EncodeUint32(v uint32) []byte

func EncodeUint64Value

func EncodeUint64Value(v uint64) []byte

EncodeByteValue encodes a uint64 as a Value (of type Uvarint) for the MVT protobuf

func EncodeUvarint

func EncodeUvarint(v uint64) []byte

EncodeUvarint returns a byte buffer with the bytes representing the Uvarint value of v

func EncodeVarint

func EncodeVarint(v int64) []byte

EncodeUvarint returns a byte buffer with the bytes representing the Varint value of v

func MercatorBoundsToGeoBounds

func MercatorBoundsToGeoBounds(b [4]float64) [4]float64

Types

type ByteColumn

type ByteColumn struct {
	Name string
	Type string // MVT type
	// contains filtered or unexported fields
}

ByteColumn represents a ByteColumn of MVT encoded value data

func NewByteColumn

func NewByteColumn(name string, colType string, values []colValue) *ByteColumn

func NewEmptyByteColumn

func NewEmptyByteColumn(name string, colType string, size int) *ByteColumn

func (*ByteColumn) GetValue

func (c *ByteColumn) GetValue(i int) []byte

func (*ByteColumn) SetValue

func (c *ByteColumn) SetValue(i int, value []byte)

func (*ByteColumn) Size

func (c *ByteColumn) Size() int

func (*ByteColumn) Take

func (c *ByteColumn) Take(indexes []int) *ByteColumn

Take creates a new ByteColumn by taking values from the ByteColumn specified by integer indexes. Out of bounds indexes will cause a panic.

type FeatureTable

type FeatureTable struct {
	// contains filtered or unexported fields
}

FeatureTable is a data structure for holding feature information as a GeometryArray and array of encoded attribute data

func ReadFeather

func ReadFeather(path string, idColName string) (*FeatureTable, error)

func (*FeatureTable) Column

func (t *FeatureTable) Column(i int) *ByteColumn

func (*FeatureTable) EncodeToLayer

func (t *FeatureTable) EncodeToLayer(name string, tile *tiles.TileID, config *tiles.EncodingConfig) ([]byte, error)

func (*FeatureTable) Geometry

func (t *FeatureTable) Geometry() *geos.GeometryArray

func (*FeatureTable) GetLayerInfo

func (t *FeatureTable) GetLayerInfo(name string, description string, minZoom uint8, maxZoom uint8) (*LayerInfo, error)

func (*FeatureTable) NumCols

func (t *FeatureTable) NumCols() int

func (*FeatureTable) Size

func (t *FeatureTable) Size() int

func (*FeatureTable) Take

func (t *FeatureTable) Take(indexes []int) *FeatureTable

type LayerInfo

type LayerInfo struct {
	Name        string            `json:"id"`
	Description string            `json:"description"`
	Minzoom     uint8             `json:"minzoom"`
	Maxzoom     uint8             `json:"maxzoom"`
	Fields      map[string]string `json:"fields"`
}

Jump to

Keyboard shortcuts

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