tile_proxy

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

tile_cache.go

tile_proxy.go

tile_utils.go

Index

Constants

View Source
const (
	CoordWGS84 = "0" // WGS84
	CoordGCJ02 = "1" // 火星坐标系
	CoordBD09  = "2" // 百度坐标系
)

坐标系类型

View Source
const (
	MaxRetries   = 3                      // 最大重试次数
	RetryDelay   = 500 * time.Millisecond // 重试延迟
	RetryBackoff = 2                      // 退避倍数
)

重试配置

View Source
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

func GlobalPixelToTile(px, py float64, tileSize int) (tileX, tileY int, offsetX, offsetY float64)

GlobalPixelToTile 全局像素坐标转瓦片坐标

Types

type CoordTransformFunc

type CoordTransformFunc func(lon, lat float64) (float64, float64)

CoordTransformFunc 坐标转换函数类型

type CropInfo

type CropInfo struct {
	// 在拼接画布上的裁剪起点
	CropX float64
	CropY float64
	// 裁剪宽高
	CropWidth  float64
	CropHeight float64
}

CalculateRequiredTilesAndCrop 计算需要请求的瓦片范围和裁剪信息

type FetchedTile

type FetchedTile struct {
	Data   []byte
	X      int
	Y      int
	Format string
	Err    error
}

FetchedTile 获取的瓦片数据

type MemCacheItem

type MemCacheItem struct {
	Data       []byte
	AccessTime time.Time
}

MemCacheItem 内存缓存项(用于热点数据)

type PixelCoord

type PixelCoord struct {
	X float64
	Y float64
}

PixelCoord 像素坐标

func LonLatToGlobalPixel

func LonLatToGlobalPixel(lon, lat float64, z int, tileSize int) PixelCoord

LonLatToGlobalPixel 经纬度转全局像素坐标

type TileBounds

type TileBounds struct {
	MinLon float64
	MinLat float64
	MaxLon float64
	MaxLat float64
}

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

func NewTileCache(maxMemItems int, ttl time.Duration) *TileCache

NewTileCache 创建瓦片缓存

func (*TileCache) Clear

func (c *TileCache) Clear()

Clear 清空缓存

func (*TileCache) Close

func (c *TileCache) Close() error

Close 关闭缓存

func (*TileCache) Delete

func (c *TileCache) Delete(key string)

Delete 删除缓存

func (*TileCache) Get

func (c *TileCache) Get(key string) ([]byte, bool)

Get 获取缓存

func (*TileCache) Set

func (c *TileCache) Set(key string, data []byte)

Set 设置缓存

func (*TileCache) SetWithType

func (c *TileCache) SetWithType(key string, data []byte, contentType string)

SetWithType 设置缓存(带内容类型)

func (*TileCache) Size

func (c *TileCache) Size() int

Size 获取缓存大小

func (*TileCache) Stats

func (c *TileCache) Stats() map[string]interface{}

Stats 获取缓存统计信息

type TileConfig

type TileConfig struct {
	TileSize int // 瓦片大小,如256或512
}

TileConfig 瓦片配置

func DefaultTileConfig

func DefaultTileConfig() *TileConfig

DefaultTileConfig 默认瓦片配置

type TileCoord

type TileCoord struct {
	Z int
	X int
	Y int
}

TileCoord 瓦片坐标

func LonLatToTileCoord

func LonLatToTileCoord(lon, lat float64, z int) TileCoord

LonLatToTileCoord 经纬度转瓦片坐标

type TileProxyService

type TileProxyService struct {
	// contains filtered or unexported fields
}

TileProxyService 瓦片代理服务

func NewTileProxyService

func NewTileProxyService() *TileProxyService

NewTileProxyService 创建瓦片代理服务

func (*TileProxyService) Close

func (s *TileProxyService) Close() error

Close 关闭服务

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 注册路由

type TileRange

type TileRange struct {
	MinX int
	MaxX int
	MinY int
	MaxY int
}

TileRange 瓦片范围

type TileRequest

type TileRequest struct {
	MapID uint
	Z     int
	X     int
	Y     int
}

TileRequest 瓦片请求参数

Jump to

Keyboard shortcuts

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