Documentation
¶
Overview ¶
tile_cache.go
tile_proxy.go
safe_tile_processor.go
tile_utils.go
webtile_downloader.go
webtile_handler.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 BoundingBox
- type CoordTransformFunc
- type CropInfo
- type DownloadRequest
- type DownloadSession
- type DownloadTask
- type FetchedTile
- type GeoJSONFeature
- type GeoJSONFeatureCollection
- type GeoJSONGeometry
- type MemCacheItem
- type PendingTask
- type PixelCoord
- type ProcessTileResult
- type ProgressMessage
- 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 TileIndex
- type TileProxyService
- type TileRange
- type TileRequest
- type WebMercatorBounds
- type WebTileDownloader
- type WebTileHandler
- func (h *WebTileHandler) Close() error
- func (h *WebTileHandler) ConnectWebSocket(c *gin.Context)
- func (h *WebTileHandler) DownloadResult(c *gin.Context)
- func (h *WebTileHandler) GetTaskStatus(c *gin.Context)
- func (h *WebTileHandler) InitDownload(c *gin.Context)
- func (h *WebTileHandler) RegisterRoutes(r *gin.RouterGroup)
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 BoundingBox ¶ added in v1.7.4
type CoordTransformFunc ¶
CoordTransformFunc 坐标转换函数类型
type CropInfo ¶
type CropInfo struct {
// 在拼接画布上的裁剪起点
CropX float64
CropY float64
// 裁剪宽高
CropWidth float64
CropHeight float64
}
CalculateRequiredTilesAndCrop 计算需要请求的瓦片范围和裁剪信息
type DownloadRequest ¶ added in v1.7.4
type DownloadRequest struct {
MapName string `json:"mapName" binding:"required"`
ZoomLevel int `json:"zoomLevel" binding:"required"`
GeoJSON json.RawMessage `json:"geoJson" binding:"required"`
}
DownloadRequest 下载请求参数
type DownloadSession ¶ added in v1.7.4
type DownloadSession struct {
// contains filtered or unexported fields
}
DownloadSession 下载会话
type DownloadTask ¶ added in v1.7.4
type DownloadTask struct {
ID string `json:"id"`
MapName string `json:"mapName"`
ZoomLevel int `json:"zoomLevel"`
Status string `json:"status"` // pending, running, completed, failed
Progress float64 `json:"progress"`
TotalTiles int `json:"totalTiles"`
DownloadedTiles int `json:"downloadedTiles"`
FailedTiles int `json:"failedTiles"`
Message string `json:"message"`
OutputFile string `json:"outputFile"`
CreatedAt time.Time `json:"createdAt"`
StartedAt *time.Time `json:"startedAt"`
CompletedAt *time.Time `json:"completedAt"`
}
DownloadTask 下载任务
type FetchedTile ¶
FetchedTile 获取的瓦片数据
type GeoJSONFeature ¶ added in v1.7.4
type GeoJSONFeature struct {
Type string `json:"type"`
Geometry GeoJSONGeometry `json:"geometry"`
Properties interface{} `json:"properties"`
}
type GeoJSONFeatureCollection ¶ added in v1.7.4
type GeoJSONFeatureCollection struct {
Type string `json:"type"`
Features []GeoJSONFeature `json:"features"`
}
type GeoJSONGeometry ¶ added in v1.7.4
type GeoJSONGeometry struct {
Type string `json:"type"`
Coordinates json.RawMessage `json:"coordinates"`
}
type MemCacheItem ¶
MemCacheItem 内存缓存项(用于热点数据)
type PendingTask ¶ added in v1.7.4
type PendingTask struct {
Task *DownloadTask
NetMap *models.NetMap
Tiles []TileIndex
BBox *BoundingBox
ZoomLevel int
CreatedAt time.Time
}
PendingTask 待处理任务(等待WebSocket连接)
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 ProgressMessage ¶ added in v1.7.4
type ProgressMessage struct {
Type string `json:"type"` // connected, progress, completed, error
TaskID string `json:"taskId,omitempty"`
Progress float64 `json:"progress,omitempty"`
Message string `json:"message,omitempty"`
Data interface{} `json:"data,omitempty"`
}
ProgressMessage WebSocket进度消息
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 注册路由
type WebMercatorBounds ¶ added in v1.7.6
func GetTileBoundsWebMercator ¶ added in v1.7.6
func GetTileBoundsWebMercator(z, x, y int) WebMercatorBounds
GetTileBoundsWebMercator 获取瓦片的 Web Mercator 边界
type WebTileDownloader ¶ added in v1.7.4
type WebTileDownloader struct {
// contains filtered or unexported fields
}
WebTileDownloader 网络瓦片下载器
func NewWebTileDownloader ¶ added in v1.7.4
func NewWebTileDownloader(outputDir string) *WebTileDownloader
NewWebTileDownloader 创建下载器
func (*WebTileDownloader) Close ¶ added in v1.7.4
func (d *WebTileDownloader) Close() error
func (*WebTileDownloader) ConnectWebSocket ¶ added in v1.7.4
func (d *WebTileDownloader) ConnectWebSocket(c *gin.Context)
ConnectWebSocket WebSocket连接处理
func (*WebTileDownloader) GetTask ¶ added in v1.7.4
func (d *WebTileDownloader) GetTask(taskID string) (*DownloadTask, bool)
GetTask 获取任务状态
func (*WebTileDownloader) InitDownload ¶ added in v1.7.4
func (d *WebTileDownloader) InitDownload(c *gin.Context)
InitDownload 初始化下载任务
type WebTileHandler ¶ added in v1.7.4
type WebTileHandler struct {
// contains filtered or unexported fields
}
WebTileHandler 网络瓦片处理器
func NewWebTileHandler ¶ added in v1.7.4
func NewWebTileHandler(outputDir string) *WebTileHandler
NewWebTileHandler 创建处理器
func (*WebTileHandler) ConnectWebSocket ¶ added in v1.7.4
func (h *WebTileHandler) ConnectWebSocket(c *gin.Context)
ConnectWebSocket WebSocket连接
func (*WebTileHandler) DownloadResult ¶ added in v1.7.4
func (h *WebTileHandler) DownloadResult(c *gin.Context)
DownloadResult 下载结果文件
func (*WebTileHandler) GetTaskStatus ¶ added in v1.7.4
func (h *WebTileHandler) GetTaskStatus(c *gin.Context)
GetTaskStatus 获取任务状态(轮询备用)
func (*WebTileHandler) InitDownload ¶ added in v1.7.4
func (h *WebTileHandler) InitDownload(c *gin.Context)
InitDownload 初始化下载任务
func (*WebTileHandler) RegisterRoutes ¶ added in v1.7.4
func (h *WebTileHandler) RegisterRoutes(r *gin.RouterGroup)
RegisterRoutes 注册路由