package
0.1.0
Repository: https://github.com/go-spatial/geom.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

MVT

GoDoc

This package contains functions and types for encoding a geometry in Mapbox Vector Tiles. This package depends on the protbuf package.

In short, a Tiles has Layers, which have Feautures. The Feature type is what holds a single geom.Geometry and associated metadata.

To encode a geometry into a tile, you need:

  • a geometry
  • a tile's geom.Extent in the same projection as the geometry
  • the size of the tile you want to output in pixels

note: the geometry must not go outside the tile extent. If this is unknown, use the clip package before encoding.

To encode:

  1. Call PrepareGeomtry, it returns a geom.Geometry that is "reprojected" into pixel values relative to the tile
  2. Add the returned geometry to a Feature, optionally with an ID and tags by calling NewFeatures.
  3. Add the feature to a Layer with a name for the layer by calling (*Layer).AddFeatures
  4. Add the layer to a Tile by calling (*Tile).AddLayers
  5. Get the protobuf tile by calling (*Tile).VTile
  6. Encode the protobuf into bytes with proto.Marshal

For an example, check the use of this package in tegola/atlas/map.go