Documentation
¶
Index ¶
- func GetEnclosingTileIDs(a, b base.Location, level uint64) (int64, int64, int64, int64)
- func LoadImage(file string) (image.Image, *image.Config, error)
- func LocationToTileID(loc base.Location, level uint64) (int64, int64)
- func SaveImageJPG(img image.Image, file string) error
- func SaveImagePNG(img image.Image, file string) error
- func StitchTiles(images [][]image.Image, config image.Config) image.Image
- func TileIDToLocation(x, y, level uint64) base.Location
- func WrapTileID(x, y, level uint64) (uint64, uint64)
- type Cache
- type FileCache
- type MapFormat
- type MapID
- type Maps
- func (m *Maps) GetEnclosingTiles(mapID MapID, a, b base.Location, level uint64, format MapFormat, highDPI bool) ([][]image.Image, [][]image.Config, error)
- func (m *Maps) GetTile(mapID MapID, x, y, z uint64, format MapFormat, highDPI bool) (image.Image, *image.Config, error)
- func (m *Maps) SetCache(c Cache)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEnclosingTileIDs ¶ added in v0.4.0
GetEnclosingTileIDs fetches a pair of tile IDs enclosing the provided pair of points
func LocationToTileID ¶ added in v0.4.0
LocationToTileID converts a lat/lon location into a tile ID
func SaveImageJPG ¶ added in v0.4.0
SaveImageJPG writes an image instance to a jpg file
func SaveImagePNG ¶ added in v0.4.0
SaveImagePNG writes an image instance to a png file
func StitchTiles ¶ added in v0.4.0
StitchTiles combines a 2d array of image tiles into a single larger image Note that all images must have the same dimensions for this to work
func TileIDToLocation ¶ added in v0.4.0
TileIDToLocation converts a tile ID to a lat/lon location
func WrapTileID ¶ added in v0.4.0
WrapTileID wraps tile IDs by level for api requests eg. Tile (X:16, Y:10, level:4 ) will become (X:0, Y:10, level:4)
Types ¶
type Cache ¶ added in v0.4.0
type Cache interface {
Save(mapID MapID, x, y, level uint64, format MapFormat, highDPI bool, img image.Image) error
Fetch(mapID MapID, x, y, level uint64, format MapFormat, highDPI bool) (image.Image, *image.Config, error)
}
Cache interface defines an abstract tile cache This can be used to limit the number of API calls required to fetch previously fetched tiles
type FileCache ¶ added in v0.4.0
type FileCache struct {
// contains filtered or unexported fields
}
FileCache is a simple file-based caching implementation for map tiles This does not implement any mechanisms for deletion / removal, and as such is not suitable for production use
func NewFileCache ¶ added in v0.4.0
NewFileCache creates a new file cache instance
type MapFormat ¶
type MapFormat string
const ( MapFormatPng MapFormat = "png" // true color PNG MapFormatPng32 MapFormat = "png32" // 32 color indexed PNG MapFormatPng64 MapFormat = "png64" // 64 color indexed PNG MapFormatPng128 MapFormat = "png128" // 128 color indexed PNG MapFormatPng256 MapFormat = "png256" // 256 color indexed PNG MapFormatPngRaw MapFormat = "pngraw" // Raw PNG (only for MapIDTerrainRGB) MapFormatJpg70 MapFormat = "jpg70" // 70% quality JPG MapFormatJpg80 MapFormat = "jpg80" // 80% quality JPG MapFormatJpg90 MapFormat = "jpg90" // 90% quality JPG MapFormatVectorTile MapFormat = "mvt" // Vector Tile )
type MapID ¶
type MapID string
const ( MapIDStreets MapID = "mapbox.streets" MapIDLight MapID = "mapbox.light" MapIDDark MapID = "mapbox.dark" MapIDSatellite MapID = "mapbox.satellite" MapIDStreetsSatellite MapID = "mapbox.streets-satellite" MapIDWheatpaste MapID = "mapbox.wheatpaste" MapIDStreetsBasic MapID = "mapbox.streets-basic" MapIDComic MapID = "mapbox.comic" MapIDOutdoors MapID = "mapbox.outdoors" MapIDRunBikeHike MapID = "mapbox.run-bike-hike" MapIDPencil MapID = "mapbox.pencil" MapIDPirates MapID = "mapbox.pirates" MapIDEmerald MapID = "mapbox.emerald" MapIDHighContrast MapID = "mapbox.high-contrast" MapIDTerrainRGB MapID = "mapbox.terrain-rgb" )
type Maps ¶
type Maps struct {
// contains filtered or unexported fields
}
Maps api wrapper instance
func (*Maps) GetEnclosingTiles ¶ added in v0.4.0
func (m *Maps) GetEnclosingTiles(mapID MapID, a, b base.Location, level uint64, format MapFormat, highDPI bool) ([][]image.Image, [][]image.Config, error)
GetEnclosingTiles fetches a 2d array of the tiles enclosing a given point