Documentation
¶
Overview ¶
tile_cache.go
tile_proxy.go
safe_tile_processor.go
tile_utils.go
Index ¶
- Constants
- func CalculateRequiredTilesWithCrop(topLeftPixel, bottomRightPixel PixelCoord, tileSize int) (TileRange, CropInfo)
- func GlobalPixelToTile(px, py float64, tileSize int) (tileX, tileY int, offsetX, offsetY float64)
- func SafeImageProcess(ctx context.Context, tiles []FetchedTile, tileRange TileRange, tileSize int, ...) ([]byte, error)
- type CoordTransformFunc
- type CropInfo
- type FetchedTile
- type MemCacheItem
- type PixelCoord
- type ProcessTileResult
- type SafeTileProcessor
- type TileBounds
- type TileCache
- func (c *TileCache) Clear()
- func (c *TileCache) Close() error
- func (c *TileCache) Delete(key string)
- func (c *TileCache) Get(key string) ([]byte, bool)
- func (c *TileCache) Set(key string, data []byte)
- func (c *TileCache) SetWithType(key string, data []byte, contentType string)
- func (c *TileCache) Size() int
- func (c *TileCache) Stats() map[string]interface{}
- type TileConfig
- type TileCoord
- type TileProxyService
- type TileRange
- type TileRequest
Constants ¶
const ( CoordWGS84 = "0" // WGS84 CoordGCJ02 = "1" // 火星坐标系 CoordBD09 = "2" // 百度坐标系 )
坐标系类型
const ( MaxRetries = 3 // 最大重试次数 RetryDelay = 500 * time.Millisecond // 重试延迟 RetryBackoff = 2 // 退避倍数 )
重试配置
const ( EarthRadius = 6378137.0 OriginShift = math.Pi * EarthRadius // 20037508.342789244 )
Variables ¶
This section is empty.
Functions ¶
func CalculateRequiredTilesWithCrop ¶
func CalculateRequiredTilesWithCrop( topLeftPixel, bottomRightPixel PixelCoord, tileSize int, ) (TileRange, CropInfo)
CalculateRequiredTilesWithCrop 计算需要请求的瓦片范围和精确裁剪信息
func GlobalPixelToTile ¶
GlobalPixelToTile 全局像素坐标转瓦片坐标
Types ¶
type CoordTransformFunc ¶
CoordTransformFunc 坐标转换函数类型
type CropInfo ¶
type CropInfo struct {
// 在拼接画布上的裁剪起点
CropX float64
CropY float64
// 裁剪宽高
CropWidth float64
CropHeight float64
}
CalculateRequiredTilesAndCrop 计算需要请求的瓦片范围和裁剪信息
type FetchedTile ¶
FetchedTile 获取的瓦片数据
type MemCacheItem ¶
MemCacheItem 内存缓存项(用于热点数据)
type PixelCoord ¶
PixelCoord 像素坐标
func LonLatToGlobalPixel ¶
func LonLatToGlobalPixel(lon, lat float64, z int, tileSize int) PixelCoord
LonLatToGlobalPixel 经纬度转全局像素坐标
type ProcessTileResult ¶ added in v1.6.6
ProcessTileResult 处理结果
type SafeTileProcessor ¶ added in v1.6.6
type SafeTileProcessor struct {
// contains filtered or unexported fields
}
SafeTileProcessor 安全的瓦片处理器
func NewSafeTileProcessor ¶ added in v1.6.6
func NewSafeTileProcessor(maxConcurrent int) *SafeTileProcessor
NewSafeTileProcessor 创建安全处理器
func (*SafeTileProcessor) ProcessWithRecover ¶ added in v1.6.6
func (s *SafeTileProcessor) ProcessWithRecover( ctx context.Context, processFn func() ([]byte, error), ) (result ProcessTileResult)
ProcessWithRecover 带恢复的处理
type TileBounds ¶
TileBounds 瓦片边界(WGS84经纬度)
func GetTileBoundsWGS84 ¶
func GetTileBoundsWGS84(z, x, y int) TileBounds
GetTileBoundsWGS84 获取瓦片的WGS84边界
type TileCache ¶
type TileCache struct {
// contains filtered or unexported fields
}
TileCache SQLite瓦片缓存
func NewTileCache ¶
NewTileCache 创建瓦片缓存
func (*TileCache) SetWithType ¶
SetWithType 设置缓存(带内容类型)
type TileProxyService ¶
type TileProxyService struct {
// contains filtered or unexported fields
}
TileProxyService 瓦片代理服务
func NewTileProxyService ¶
func NewTileProxyService() *TileProxyService
NewTileProxyService 创建瓦片代理服务
func (*TileProxyService) HandleCacheStats ¶
func (s *TileProxyService) HandleCacheStats(c *gin.Context)
HandleCacheStats 获取缓存统计
func (*TileProxyService) HandleClearCache ¶
func (s *TileProxyService) HandleClearCache(c *gin.Context)
HandleClearCache 清空缓存
func (*TileProxyService) HandleTileRequest ¶
func (s *TileProxyService) HandleTileRequest(c *gin.Context)
HandleTileRequest 处理瓦片请求
func (*TileProxyService) RegisterRoutes ¶
func (s *TileProxyService) RegisterRoutes(r *gin.RouterGroup)
RegisterRoutes 注册路由