Documentation ¶
Overview ¶
Package mbtiles reads and writes files in the MBTiles format. See https://github.com/mapbox/mbtiles-spec.
Index ¶
- type MetadataJson
- type MetadataJsonVectorLayer
- type Optimizations
- type Reader
- type TileData
- type Writer
- func (w *Writer) BulkInsertTile(data []TileData) error
- func (w *Writer) Close() error
- func (w *Writer) CreateMetadata() error
- func (w *Writer) CreateTileIndex() error
- func (w *Writer) CreateTiles() error
- func (w *Writer) DeleteMetadata() error
- func (w *Writer) DeleteTileIndex() error
- func (w *Writer) InsertMetadata(name string, value string) error
- func (w *Writer) InsertTile(z, x, y int, tileData []byte) error
- func (w *Writer) SelectMetadata(name string) (string, error)
- func (w *Writer) SelectTile(z, x, y int) ([]byte, error)
- func (w *Writer) SetOptimizations(opts Optimizations) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetadataJson ¶
type MetadataJson struct {
VectorLayers []MetadataJsonVectorLayer `json:"vector_layers"` // Defines the vector layers in this mbtiles file. Required for vector tilesets (mvt/pbf). Not necessary for raster image (png/webp/jpg/etc) mbtiles files.
}
MetadataJson is the metadata required by the mbtiles spec to be present for vector tiles in the metadata table. This struct should be marshaled to a UTF-8 string and the value stored with key name `json`.
See https://github.com/mapbox/mbtiles-spec/blob/master/1.3/spec.md#vector-tileset-metadata
type MetadataJsonVectorLayer ¶
type MetadataJsonVectorLayer struct { ID *string `json:"id"` // The layer ID, which is referred to as the name of the layer in the Mapbox Vector Tile spec. Description *string `json:"description,omitempty"` // A human-readable description of the layer's contents. MinZoom *int `json:"minzoom,omitempty"` // The lowest zoom level whose tiles this layer appears in. MaxZoom *int `json:"maxzoom,omitempty"` // The highest zoom level whose tiles this layer appears in. Fields map[string]string `json:"fields"` // Fields has keys and values are the names and types of attributes available in this layer. Each type MUST be the string "Number", "Boolean", or "String". Attributes whose type varies between features SHOULD be listed as "String". }
MetadataJsonVectorLayer contains information about each vector tile layer in this mbtiles file.
type Optimizations ¶
type Optimizations struct { // Synchronous turns ON or OFF the statement PRAGMA synchronous = OFF. SynchronousOff bool // JournalModeMemory turns ON or OFF the statement PRAGMA journal_mode = MEMORY. JournalModeMemory bool }
Optimizations are options that can be turned on/off for writing mbtiles files, however they do have side-effects so best to research before using them.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
A Reader reads a tileset.
func NewReaderWithDB ¶
NewReaderWithDB returns a new Reader initialized with a sql.Database. This is useful for instantiating alternative implementations of sqlite.
func (*Reader) SelectMetadata ¶
SelectMetadata returns the metadata value for 'name'
func (*Reader) SelectTile ¶
SelectTile returns the tile at (z, x, y).
type TileData ¶
type TileData struct { X int // X coordinate in ZXY format Y int // Y coordinate in ZXY format Z int // Z coordinate in ZXY format Data []byte // Tile data, must be gzip encoded for mbtiles }
TileData represents a single tile for writing to the mbtiles file.
type Writer ¶
type Writer struct { Reader // contains filtered or unexported fields }
A Writer writes a tileset. It should be created with NewWriter().
func NewWriterWithDB ¶
NewWriterWithDB returns a new Writer initialized with a sql.Database. This is useful for instantiating alternative implementations of sqlite.
func (*Writer) BulkInsertTile ¶
BulkInsertTile inserts multiple tiles at the coordinates provided (z, x, y). This can be faster because it reduces the number of transactions. By default, sqlite wraps each insert in a transaction.
func (*Writer) CreateMetadata ¶
CreateMetadata creates the metadata table if it does not already exist.
func (*Writer) CreateTileIndex ¶
CreateTileIndex generates the standard index on the tiles table.
func (*Writer) CreateTiles ¶
CreateTiles creates the tiles table if it does not already exist.
func (*Writer) DeleteMetadata ¶
DeleteMetadata removes the metadata table, useful for resetting the metadata in the mbtiles file.
func (*Writer) DeleteTileIndex ¶
DeleteTileIndex removes the tile index, useful for speeding up bulk inserts.
func (*Writer) InsertMetadata ¶
InsertMetadata inserts a name, value row to the metadata store.
func (*Writer) InsertTile ¶
InsertTile inserts a tile at (z, x, y).
func (*Writer) SelectMetadata ¶
SelectMetadata returns the metadata value for name.
func (*Writer) SelectTile ¶
SelectTile returns the tile at (z, x, y).
func (*Writer) SetOptimizations ¶
func (w *Writer) SetOptimizations(opts Optimizations) error
SetOptimizations can be used to turn on or off Optimization options.