Documentation
¶
Overview ¶
Package tilemap implements a compact on-disk store for a single zoom level of map tiles.
A tilemap file is laid out as a fixed size index region followed by a densely packed data region:
[ datapointer * 4^zoom ][ tile bytes ... ]
Each datapointer is 10 bytes: a 48 bit absolute file offset and a 32 bit size. The index region is memory mapped so that looking up a tile is a single bounds check and a 10 byte decode. Identical tiles (think ocean) are stored once and referenced by every tile that shares the bytes.
Index ¶
- Constants
- Variables
- type Tilemap
- func (w *Tilemap) Add(x, y int, buff []byte) (err error)
- func (w *Tilemap) Close() (err error)
- func (w *Tilemap) Flush() error
- func (w *Tilemap) GetTile(x, y int) (buff []byte, err error)
- func (w *Tilemap) Has(x, y int) (bool, error)
- func (w *Tilemap) Size() int64
- func (w *Tilemap) Sync() error
- func (w *Tilemap) Zoom() int
Constants ¶
const ( // MaxZoom is the largest zoom level a tilemap can hold. MaxZoom = maxDimension // MaxTileSize is the largest single tile that can be stored. MaxTileSize = 1 << 24 )
const ( NO_COMP uint32 = 0x00000400 COMP uint32 = 0x00000004 NO_COW uint32 = 0x00800000 )
Variables ¶
var ( ErrInvalidBufferSize = errors.New("invalid buffer size") ErrInvalidDimension = errors.New("invalid tile zoom") ErrInvalidTileID = errors.New("invalid tile id") ErrInvalidTileBuffer = errors.New("invalid tile buffer") ErrInvalidDatapointer = errors.New("invalid tile datapointer, file may be corrupt") ErrInvalidDPRegionSize = errors.New("invalid tile datapointer region size, file may be corrupt") ErrPartialWrite = errors.New("partial write") ErrReadOnly = errors.New("tilemap is read only") ErrClosed = errors.New("tilemap is closed") ErrTileNotFound = errors.New("tile not found") ErrInvalidPath = errors.New("invalid path") )
Functions ¶
This section is empty.
Types ¶
type Tilemap ¶
type Tilemap struct {
// contains filtered or unexported fields
}
Tilemap is a single zoom level tile store. It is safe for concurrent use.
func NewTilemap ¶
NewTilemap opens (or in read/write mode creates) the tilemap at pth for the given zoom level. When ro is true the file is opened read only and the Add method returns ErrReadOnly.
func (*Tilemap) Add ¶
Add stores buff as the tile at x, y. If an identical tile has already been added through this handle the bytes are shared rather than written again.
func (*Tilemap) Close ¶
Close flushes outstanding writes and releases the file and mappings. Closing an already closed tilemap is a no-op.
func (*Tilemap) GetTile ¶
GetTile returns a copy of the tile stored at x, y. ErrTileNotFound is returned for a tile that was never added.
Directories
¶
| Path | Synopsis |
|---|---|
|
tools
|
|
|
httpClient
command
httpClient builds a tilemap for a single zoom level by requesting every tile directly from a tile server.
|
httpClient builds a tilemap for a single zoom level by requesting every tile directly from a tile server. |
|
tarImport
command
|
|
|
webserver
command
|