Documentation ¶
Index ¶
- Constants
- Variables
- func GetEnclosingTileIDs(a, b base.Location, level uint64) (uint64, uint64, uint64, uint64)
- func HeightToPixel(alt float64) (uint8, uint8, uint8)
- func LoadImage(file string) (image.Image, *image.Config, error)
- func LocationToTileID(loc base.Location, level uint64) (uint64, uint64)
- func MercatorLocationToPixel(lat, lng float64, zoom, size uint64) (float64, float64)
- func MercatorLocationToTileID(lat, lng float64, zoom, size uint64) (uint64, uint64)
- func MercatorPixelToLocation(x, y float64, zoom, size uint64) (float64, float64)
- func PixelToHeight(r, g, b uint8) float64
- func SaveImageJPG(img image.Image, file string) error
- func SaveImagePNG(img image.Image, file string) error
- func TileIDToLocation(x, y float64, level uint64) base.Location
- func WrapTileID(x, y, level uint64) (uint64, uint64)
- type Cache
- type DrawConfig
- type FileCache
- type Interpolate
- type Justify
- type MapFormat
- type MapID
- type Maps
- func (m *Maps) FastGetEnclosingTiles(mapID MapID, a, b base.Location, level uint64, format MapFormat, highDPI bool) ([][]Tile, error)
- func (m *Maps) GetEnclosingTiles(mapID MapID, a, b base.Location, level uint64, format MapFormat, highDPI bool) ([][]Tile, error)
- func (m *Maps) GetTile(mapID MapID, x, y, z uint64, format MapFormat, highDPI bool) (*Tile, error)
- func (m *Maps) SetCache(c Cache)
- type Tile
- func (t *Tile) Clone() Tile
- func (t *Tile) DrawGlobalXY(src image.Image, x, y int, config DrawConfig) error
- func (t *Tile) DrawLine(loc1, loc2 base.Location, c color.Color)
- func (t *Tile) DrawLocalXY(src image.Image, x, y int, config DrawConfig) error
- func (t *Tile) DrawLocation(src image.Image, loc base.Location, config DrawConfig)
- func (t *Tile) DrawPoint(loc base.Location, size uint64, c color.Color) error
- func (t *Tile) FlattenAltitudes(maxHeight float64) Tile
- func (t *Tile) GetAltitude(loc base.Location) (float64, error)
- func (t *Tile) GetHighestAltitude() float64
- func (t *Tile) InterpolateAltitudes(loc1, loc2 base.Location) []float64
- func (t *Tile) InterpolateGlobalXY(x1, y1, x2, y2 int, interpolate Interpolate) error
- func (t *Tile) InterpolateLocalXY(x1, y1, x2, y2 int, interpolate Interpolate)
- func (t *Tile) InterpolateLocations(loc1, loc2 base.Location, interpolate Interpolate) error
- func (t *Tile) LocationToPixel(loc base.Location) (float64, float64, error)
- func (t *Tile) PixelToLocation(x, y float64) (*base.Location, error)
Constants ¶
const ( // D2R helper for converting degrees to radians D2R = math.Pi / 180 // R2D helper for converting radians to degrees R2D = 180 / math.Pi )
const ( SizeStandard uint64 = 256 SizeHighDPI uint64 = 512 )
Variables ¶
var Center = DrawConfig{JustifyCenter, JustifyCenter}
Center preconfigured centering helper
Functions ¶
func GetEnclosingTileIDs ¶ added in v0.3.0
GetEnclosingTileIDs fetches a pair of tile IDs enclosing the provided pair of points
func LocationToTileID ¶ added in v0.3.0
LocationToTileID converts a lat/lon location into a tile ID
func MercatorLocationToPixel ¶ added in v0.4.1
MercatorLocationToPixel converts a lat/lng/zoom location (in degrees) to a pixel location in the global space
func MercatorLocationToTileID ¶ added in v0.4.1
MercatorLocationToTileID builds on MercatorLocationToPixel to fetch the TileID of a given location
func MercatorPixelToLocation ¶ added in v0.4.1
MercatorPixelToLocation converts a given (global) pixel location and zoom level to a lat and lng (in degrees)
func PixelToHeight ¶ added in v0.4.1
PixelToHeight Converts a pixel to a height value for mapbox terrain tiles Equation from https://www.mapbox.com/blog/terrain-rgb/
func SaveImageJPG ¶ added in v0.3.0
SaveImageJPG writes an image instance to a jpg file
func SaveImagePNG ¶ added in v0.3.0
SaveImagePNG writes an image instance to a png file
func TileIDToLocation ¶ added in v0.3.0
TileIDToLocation converts a tile ID to a lat/lon location
func WrapTileID ¶ added in v0.3.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.3.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 DrawConfig ¶ added in v0.4.1
DrawConfig configures image drawing
type FileCache ¶ added in v0.3.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.3.0
NewFileCache creates a new file cache instance
type Interpolate ¶ added in v0.4.1
Interpolate function to be passed to generic line interpolator
type MapFormat ¶
type MapFormat string
MapFormat specifies the format in which to return the map tiles
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 )
Map formats
type MapID ¶
type MapID string
MapID selects which map to fetch from the API
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" )
Map IDs
type Maps ¶
type Maps struct {
// contains filtered or unexported fields
}
Maps api wrapper instance
func (*Maps) FastGetEnclosingTiles ¶ added in v0.4.1
func (*Maps) GetEnclosingTiles ¶ added in v0.3.0
func (m *Maps) GetEnclosingTiles(mapID MapID, a, b base.Location, level uint64, format MapFormat, highDPI bool) ([][]Tile, error)
GetEnclosingTiles fetches a 2d array of the tiles enclosing a given point
type Tile ¶ added in v0.4.1
type Tile struct { draw.Image Level uint64 // Tile zoom level Size uint64 // Tile size X, Y uint64 // Tile X and Y postions (Web Mercurator projection) }
Tile is a wrapper around an image that includes positioning data
func StitchTiles ¶ added in v0.3.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 (*Tile) DrawGlobalXY ¶ added in v0.4.1
DrawGlobalXY draws the provided image at the global X/Y coordinates
func (*Tile) DrawLine ¶ added in v0.4.1
DrawLine uses InterpolateLocations to draw a line between two points
func (*Tile) DrawLocalXY ¶ added in v0.4.1
DrawLocalXY draws the provided image at the local X/Y coordinates
func (*Tile) DrawLocation ¶ added in v0.4.1
DrawLocation draws the provided image at the provided lat lng
func (*Tile) FlattenAltitudes ¶ added in v0.4.1
func (*Tile) GetAltitude ¶ added in v0.4.1
func (*Tile) GetHighestAltitude ¶ added in v0.4.1
func (*Tile) InterpolateAltitudes ¶ added in v0.4.1
func (*Tile) InterpolateGlobalXY ¶ added in v0.4.1
func (t *Tile) InterpolateGlobalXY(x1, y1, x2, y2 int, interpolate Interpolate) error
InterpolateGlobalXY interpolates a line between two global points and calls the interpolate function on each point
func (*Tile) InterpolateLocalXY ¶ added in v0.4.1
func (t *Tile) InterpolateLocalXY(x1, y1, x2, y2 int, interpolate Interpolate)
InterpolateLocalXY interpolates a line between two local points and calls the interpolate function on each point
func (*Tile) InterpolateLocations ¶ added in v0.4.1
func (t *Tile) InterpolateLocations(loc1, loc2 base.Location, interpolate Interpolate) error
InterpolateLocations interpolates a line between two locations and calls the interpolate function on each point
func (*Tile) LocationToPixel ¶ added in v0.4.1
LocationToPixel translates a global location to a pixel on the tile