maps

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnclosingTileIDs added in v0.4.0

func GetEnclosingTileIDs(a, b base.Location, level uint64) (int64, int64, int64, int64)

GetEnclosingTileIDs fetches a pair of tile IDs enclosing the provided pair of points

func LoadImage added in v0.4.0

func LoadImage(file string) (image.Image, *image.Config, error)

LoadImage loads an image from a file

func LocationToTileID added in v0.4.0

func LocationToTileID(loc base.Location, level uint64) (int64, int64)

LocationToTileID converts a lat/lon location into a tile ID

func SaveImageJPG added in v0.4.0

func SaveImageJPG(img image.Image, file string) error

SaveImageJPG writes an image instance to a jpg file

func SaveImagePNG added in v0.4.0

func SaveImagePNG(img image.Image, file string) error

SaveImagePNG writes an image instance to a png file

func StitchTiles added in v0.4.0

func StitchTiles(images [][]image.Image, config image.Config) image.Image

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

func TileIDToLocation(x, y, level uint64) base.Location

TileIDToLocation converts a tile ID to a lat/lon location

func WrapTileID added in v0.4.0

func WrapTileID(x, y, level uint64) (uint64, uint64)

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

func NewFileCache(basePath string) (*FileCache, error)

NewFileCache creates a new file cache instance

func (*FileCache) Fetch added in v0.4.0

func (fc *FileCache) Fetch(mapID MapID, x, y, level uint64, format MapFormat, highDPI bool) (image.Image, *image.Config, error)

Fetch fetches an image from the file cache if possible

func (*FileCache) Save added in v0.4.0

func (fc *FileCache) Save(mapID MapID, x, y, level uint64, format MapFormat, highDPI bool, img image.Image) error

Save saves an image to the file cache

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 NewMaps

func NewMaps(base *base.Base) *Maps

NewMaps Create a new Maps API wrapper

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

func (*Maps) GetTile added in v0.4.0

func (m *Maps) GetTile(mapID MapID, x, y, z uint64, format MapFormat, highDPI bool) (image.Image, *image.Config, error)

GetTile fetches the map tile for the specified location

func (*Maps) SetCache added in v0.4.0

func (m *Maps) SetCache(c Cache)

SetCache binds a cache into the map instance

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL