mvt

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: MIT Imports: 5 Imported by: 0

README

mvt

A go library for decoding MVT tiles along with its geometry

Usage

go get git.sr.ht/~jzs/mvt

data := []byte{} // Replace with your mvt data

tile := &mvt.Tile{}
if err := proto.Unmarshal(data, tile); err != nil {
	return fmt.Errorf("Unmarshal mvt: %w", err)
}

Documentation

Index

Constants

View Source
const (
	Default_Tile_Feature_Id   = uint64(0)
	Default_Tile_Feature_Type = Tile_UNKNOWN
)

Default values for Tile_Feature fields.

View Source
const (
	Default_Tile_Layer_Version = uint32(1)
	Default_Tile_Layer_Extent  = uint32(4096)
)

Default values for Tile_Layer fields.

Variables

View Source
var (
	Tile_GeomType_name = map[int32]string{
		0: "UNKNOWN",
		1: "POINT",
		2: "LINESTRING",
		3: "POLYGON",
	}
	Tile_GeomType_value = map[string]int32{
		"UNKNOWN":    0,
		"POINT":      1,
		"LINESTRING": 2,
		"POLYGON":    3,
	}
)

Enum value maps for Tile_GeomType.

View Source
var File_vector_tile_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Command

type Command struct {
	Type   CommandType
	Dx, Dy int32 // Delta X, Delta Y
}

type CommandType

type CommandType uint32
const (
	CommandMoveTo    CommandType = 1
	CommandLineTo    CommandType = 2
	CommandClosePath CommandType = 7
)

type Path

type Path []Command

func MoveTo

func MoveTo(dx, dy int32) Path

MoveTo creates a new path with the first command MoveTo

func (Path) ClosePath

func (p Path) ClosePath() Path

func (Path) LineTo

func (p Path) LineTo(dx, dy int32) Path

func (Path) MoveTo

func (p Path) MoveTo(dx, dy int32) Path

type Tile

type Tile struct {
	Layers []*Tile_Layer `protobuf:"bytes,3,rep,name=layers" json:"layers,omitempty"`
	// contains filtered or unexported fields
}

func Unmarshal added in v1.0.2

func Unmarshal(data []byte) (*Tile, error)

Unmarshal takes a byte slice and turns it into a Tile struct

func (*Tile) Descriptor deprecated

func (*Tile) Descriptor() ([]byte, []int)

Deprecated: Use Tile.ProtoReflect.Descriptor instead.

func (*Tile) GetLayers

func (x *Tile) GetLayers() []*Tile_Layer

func (*Tile) ProtoMessage

func (*Tile) ProtoMessage()

func (*Tile) ProtoReflect

func (x *Tile) ProtoReflect() protoreflect.Message

func (*Tile) Reset

func (x *Tile) Reset()

func (*Tile) String

func (x *Tile) String() string

type Tile_Feature

type Tile_Feature struct {
	Id *uint64 `protobuf:"varint,1,opt,name=id,def=0" json:"id,omitempty"`
	// Tags of this feature are encoded as repeated pairs of
	// integers.
	// A detailed description of tags is located in sections
	// 4.2 and 4.4 of the specification
	Tags []uint32 `protobuf:"varint,2,rep,packed,name=tags" json:"tags,omitempty"`
	// The type of geometry stored in this feature.
	Type *Tile_GeomType `protobuf:"varint,3,opt,name=type,enum=vector_tile.Tile_GeomType,def=0" json:"type,omitempty"`
	// Contains a stream of commands and parameters (vertices).
	// A detailed description on geometry encoding is located in
	// section 4.3 of the specification.
	Geometry []uint32 `protobuf:"varint,4,rep,packed,name=geometry" json:"geometry,omitempty"`
	// contains filtered or unexported fields
}

Features are described in section 4.2 of the specification

func (*Tile_Feature) DecodeGeometry

func (x *Tile_Feature) DecodeGeometry() Path

func (*Tile_Feature) Descriptor deprecated

func (*Tile_Feature) Descriptor() ([]byte, []int)

Deprecated: Use Tile_Feature.ProtoReflect.Descriptor instead.

func (*Tile_Feature) GetGeometry

func (x *Tile_Feature) GetGeometry() []uint32

func (*Tile_Feature) GetId

func (x *Tile_Feature) GetId() uint64

func (*Tile_Feature) GetTags

func (x *Tile_Feature) GetTags() []uint32

func (*Tile_Feature) GetType

func (x *Tile_Feature) GetType() Tile_GeomType

func (*Tile_Feature) ProtoMessage

func (*Tile_Feature) ProtoMessage()

func (*Tile_Feature) ProtoReflect

func (x *Tile_Feature) ProtoReflect() protoreflect.Message

func (*Tile_Feature) Reset

func (x *Tile_Feature) Reset()

func (*Tile_Feature) String

func (x *Tile_Feature) String() string

type Tile_GeomType

type Tile_GeomType int32

GeomType is described in section 4.3.4 of the specification

const (
	Tile_UNKNOWN    Tile_GeomType = 0
	Tile_POINT      Tile_GeomType = 1
	Tile_LINESTRING Tile_GeomType = 2
	Tile_POLYGON    Tile_GeomType = 3
)

func (Tile_GeomType) Descriptor

func (Tile_GeomType) Enum

func (x Tile_GeomType) Enum() *Tile_GeomType

func (Tile_GeomType) EnumDescriptor deprecated

func (Tile_GeomType) EnumDescriptor() ([]byte, []int)

Deprecated: Use Tile_GeomType.Descriptor instead.

func (Tile_GeomType) Number

func (Tile_GeomType) String

func (x Tile_GeomType) String() string

func (Tile_GeomType) Type

func (*Tile_GeomType) UnmarshalJSON deprecated

func (x *Tile_GeomType) UnmarshalJSON(b []byte) error

Deprecated: Do not use.

type Tile_Layer

type Tile_Layer struct {

	// Any compliant implementation must first read the version
	// number encoded in this message and choose the correct
	// implementation for this version number before proceeding to
	// decode other parts of this message.
	Version *uint32 `protobuf:"varint,15,req,name=version,def=1" json:"version,omitempty"`
	Name    *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
	// The actual features in this tile.
	Features []*Tile_Feature `protobuf:"bytes,2,rep,name=features" json:"features,omitempty"`
	// Dictionary encoding for keys
	Keys []string `protobuf:"bytes,3,rep,name=keys" json:"keys,omitempty"`
	// Dictionary encoding for values
	Values []*Tile_Value `protobuf:"bytes,4,rep,name=values" json:"values,omitempty"`
	// Although this is an "optional" field it is required by the specification.
	// See https://github.com/mapbox/vector-tile-spec/issues/47
	Extent *uint32 `protobuf:"varint,5,opt,name=extent,def=4096" json:"extent,omitempty"`
	// contains filtered or unexported fields
}

Layers are described in section 4.1 of the specification

func (*Tile_Layer) Descriptor deprecated

func (*Tile_Layer) Descriptor() ([]byte, []int)

Deprecated: Use Tile_Layer.ProtoReflect.Descriptor instead.

func (*Tile_Layer) GetExtent

func (x *Tile_Layer) GetExtent() uint32

func (*Tile_Layer) GetFeatures

func (x *Tile_Layer) GetFeatures() []*Tile_Feature

func (*Tile_Layer) GetKeys

func (x *Tile_Layer) GetKeys() []string

func (*Tile_Layer) GetName

func (x *Tile_Layer) GetName() string

func (*Tile_Layer) GetValues

func (x *Tile_Layer) GetValues() []*Tile_Value

func (*Tile_Layer) GetVersion

func (x *Tile_Layer) GetVersion() uint32

func (*Tile_Layer) ProtoMessage

func (*Tile_Layer) ProtoMessage()

func (*Tile_Layer) ProtoReflect

func (x *Tile_Layer) ProtoReflect() protoreflect.Message

func (*Tile_Layer) Reset

func (x *Tile_Layer) Reset()

func (*Tile_Layer) String

func (x *Tile_Layer) String() string

type Tile_Value

type Tile_Value struct {

	// Exactly one of these values must be present in a valid message
	StringValue *string  `protobuf:"bytes,1,opt,name=string_value,json=stringValue" json:"string_value,omitempty"`
	FloatValue  *float32 `protobuf:"fixed32,2,opt,name=float_value,json=floatValue" json:"float_value,omitempty"`
	DoubleValue *float64 `protobuf:"fixed64,3,opt,name=double_value,json=doubleValue" json:"double_value,omitempty"`
	IntValue    *int64   `protobuf:"varint,4,opt,name=int_value,json=intValue" json:"int_value,omitempty"`
	UintValue   *uint64  `protobuf:"varint,5,opt,name=uint_value,json=uintValue" json:"uint_value,omitempty"`
	SintValue   *int64   `protobuf:"zigzag64,6,opt,name=sint_value,json=sintValue" json:"sint_value,omitempty"`
	BoolValue   *bool    `protobuf:"varint,7,opt,name=bool_value,json=boolValue" json:"bool_value,omitempty"`
	// contains filtered or unexported fields
}

Variant type encoding The use of values is described in section 4.1 of the specification

func (*Tile_Value) Descriptor deprecated

func (*Tile_Value) Descriptor() ([]byte, []int)

Deprecated: Use Tile_Value.ProtoReflect.Descriptor instead.

func (*Tile_Value) GetBoolValue

func (x *Tile_Value) GetBoolValue() bool

func (*Tile_Value) GetDoubleValue

func (x *Tile_Value) GetDoubleValue() float64

func (*Tile_Value) GetFloatValue

func (x *Tile_Value) GetFloatValue() float32

func (*Tile_Value) GetIntValue

func (x *Tile_Value) GetIntValue() int64

func (*Tile_Value) GetSintValue

func (x *Tile_Value) GetSintValue() int64

func (*Tile_Value) GetStringValue

func (x *Tile_Value) GetStringValue() string

func (*Tile_Value) GetUintValue

func (x *Tile_Value) GetUintValue() uint64

func (*Tile_Value) ProtoMessage

func (*Tile_Value) ProtoMessage()

func (*Tile_Value) ProtoReflect

func (x *Tile_Value) ProtoReflect() protoreflect.Message

func (*Tile_Value) Reset

func (x *Tile_Value) Reset()

func (*Tile_Value) String

func (x *Tile_Value) String() string

Jump to

Keyboard shortcuts

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