Documentation
¶
Overview ¶
Package tileutils provides types and functions for working with slippy map tiles, MBTiles, and TileJSON
Index ¶
- func CreateMetadataJSON(tj *TileJSON) *mbtiles.MetadataJson
- func Gzip(data []byte) ([]byte, error)
- func ParseTileJSON(filename string) (*TileJSON, ZoomLayerInfo, error)
- func RoundRobinTiles(input []TileCoords, numWorkers int) [][]TileCoords
- type BoundingBox
- type CreateMetadataOptions
- type DummyWriter
- type FileWriter
- type MbTilesFormat
- type MbTilesMetadata
- type MbTilesWriter
- func (w *MbTilesWriter) BulkWrite(data []mbtiles.TileData) error
- func (w *MbTilesWriter) BulkWriteMetadata(meta MbTilesMetadata) error
- func (w *MbTilesWriter) New() (TileWriter, func(), error)
- func (w *MbTilesWriter) Write(z, x, y int, tileData []byte) error
- func (w *MbTilesWriter) WriteMetadata(name, value string) error
- type TileBulkWriter
- type TileCoords
- type TileJSON
- type TileWriter
- type VectorLayer
- type VectorQuery
- type ZoomLayerInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMetadataJSON ¶
func CreateMetadataJSON(tj *TileJSON) *mbtiles.MetadataJson
CreateMetadataJSON generates a mbtiles MetadataJson object based on the TileJSON input
func ParseTileJSON ¶
func ParseTileJSON(filename string) (*TileJSON, ZoomLayerInfo, error)
func RoundRobinTiles ¶
func RoundRobinTiles(input []TileCoords, numWorkers int) [][]TileCoords
RoundRobinTiles assigns tiles to workers in round robin fashion
Types ¶
type BoundingBox ¶
BoundingBox is a lat/lon set of coordinates for a bounding box
type CreateMetadataOptions ¶
type CreateMetadataOptions struct {
Filename string
Version string
Format MbTilesFormat
}
type DummyWriter ¶
type DummyWriter struct{}
DummyWriter doesn't do anything. It outputs info about the tile to be written to stdout. It doesn't actually write any tiles.
func (*DummyWriter) New ¶
func (fw *DummyWriter) New() (TileWriter, func(), error)
type FileWriter ¶
type FileWriter struct {
Path string
}
FileWriter writes tiles out to a directory structure. The directories are organized under the Path provided, like Path/{z}/{x}/{y}.mvt
func (*FileWriter) New ¶
func (fw *FileWriter) New() (TileWriter, func(), error)
type MbTilesFormat ¶
type MbTilesFormat string
const ( MbTilesFormatPbf MbTilesFormat = "pbf" MbTilesFormatJpg MbTilesFormat = "jpg" MbTilesFormatPng MbTilesFormat = "png" MbTilesFormatWebP MbTilesFormat = "webp" )
type MbTilesMetadata ¶
func CreateMetadata ¶
func CreateMetadata(tj *TileJSON, opts CreateMetadataOptions) MbTilesMetadata
CreateMetadata generates the (name,value) metadata pairs for .mbtiles files. Since name is required, it falls back to the filename if not provided. format is also required, so it falls back to pbf if not provided.
type MbTilesWriter ¶
MbTilesWriter outputs tiles to a mbtiles file.
Parameters:
- Filename: the output file to be written
- Writer: an instance of mbtiles.Writer to be used when writing the tiles
func (*MbTilesWriter) BulkWriteMetadata ¶
func (w *MbTilesWriter) BulkWriteMetadata(meta MbTilesMetadata) error
func (*MbTilesWriter) New ¶
func (w *MbTilesWriter) New() (TileWriter, func(), error)
func (*MbTilesWriter) WriteMetadata ¶
func (w *MbTilesWriter) WriteMetadata(name, value string) error
type TileBulkWriter ¶
type TileBulkWriter interface {
// BulkWrite commits a slice of tiles
BulkWrite(data []mbtiles.TileData) error
}
TileBulkWriter extends the TileWriter interface to include the ability to write out tiles in bulk
type TileCoords ¶
func ListTiles ¶
func ListTiles(zooms []int, tj *TileJSON) []TileCoords
ListTiles returns a list of all the tiles within the given zooms based on the TileJSON
func TilesFromFile ¶
func TilesFromFile(filename string) ([]TileCoords, error)
TilesFromFile reads the tile coordinates to generate from a file
type TileJSON ¶
type TileJSON struct {
Attribution string `json:"attribution,omitempty"`
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version,omitempty"`
MinZoom int `json:"minzoom"`
MaxZoom int `json:"maxzoom"`
Bounds []float64 `json:"bounds,omitempty"`
Center []float64 `json:"center,omitempty"`
VectorLayers []VectorLayer `json:"vector_layers"`
}
type TileWriter ¶
type TileWriter interface {
// New creates a new TileWriter for this type
New() (TileWriter, func(), error)
// Write commits a tile with tileData at the Z/X/Y coordinate
Write(z, x, y int, tileData []byte) error
}
TileWriter abstracts how to write out tiles, allowing for different formats and implementations
type VectorLayer ¶
type VectorLayer struct {
ID string `json:"id"`
Queries []VectorQuery `json:"queries"`
}
type VectorQuery ¶
type ZoomLayerInfo ¶
ZoomLayerInfo is a mapped index of queries at each zoom. map[int] where int is the zoom level. map[string][]string where string1 is the layer name/id and []string is the list of queries.