tileproxy

package module
v0.0.0-...-7109a22 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 10 Imported by: 0

README

# go-tileproxy

A high-performance tile proxy server written in Go, supporting multiple tile services and formats with caching capabilities.

## Features

- **Multiple Service Types**: Support for WMS, WMTS, Mapbox Vector Tiles, XYZ/OSM tiles, Cesium 3D Tiles, and ArcGIS REST services
- **Tile Formats**: PNG, JPEG, WebP, MVT, PBF, GeoJSON, Terrain, LERC
- **Caching System**: Local file-based cache with multiple layout options (TMS, Quadkey, ArcGIS, MapProxy)
- **Image Processing**: Tile merging, transformation, masking, and blank tile generation
- **Import/Export**: Support for MBTiles, GeoPackage, and COG formats
- **Reprojection**: Automatic tile reprojection between coordinate systems
- **Concurrent Processing**: Thread-safe operations with optimized performance

## Supported Services

- **MapboxService**: Mapbox Vector Tiles specification
- **WMSService**: Web Map Service (OGC standard) with GetMap and GetFeatureInfo support
- **WMTSService**: Web Map Tile Service (OGC standard)
- **TileService**: Standard XYZ/OSM tile services
- **CesiumService**: Cesium 3D Tiles specification
- **ArcGISService**: ArcGIS REST tile services

## Supported Tile Types

- `TILE_IMAGERY`: Raster image tiles (PNG, JPEG, WebP)
- `TILE_VECTOR`: Vector tiles (MVT, PBF, GeoJSON)
- `TILE_DEM`: Digital elevation model tiles (quantized mesh, terrain)

## Requirements

- Go 1.24 or higher

## Installation

```bash
go get github.com/flywave/go-tileproxy
```

## Usage

### Basic Example

```go
package main

import (
    "net/http"
    
    "github.com/flywave/go-tileproxy"
    "github.com/flywave/go-tileproxy/setting"
)

func main() {
    // Load configuration
    globals := &setting.GlobalsSetting{}
    services := []*setting.ProxyService{}
    cacheFactory := &setting.DefaultCacheFactory{}
    
    // Create tile proxy
    proxy := tileproxy.NewTileProxy(globals, services, cacheFactory)
    
    // Start HTTP server
    http.ListenAndServe(":8080", proxy)
}
```

### Running from Command Line

```bash
# Build the project
go build ./...

# Run tests
go test ./...

# Run the server
go run ./cmd/main.go
```

## Building

```bash
# Build all packages
go build ./...

# Build executable
go build -o tileproxy ./cmd
```

## Testing

```bash
# Run all tests
go test ./...

# Run tests with coverage
go test -cover ./...

# Run tests for a specific package
go test ./cache
go test ./service

# Run with verbose output
go test -v ./...
```

## Linting

```bash
# Format code
go fmt ./...

# Run vet
go vet ./...
```

## Project Structure

- `cache`: Cache management and local storage
- `client`: HTTP clients for different service types
- `service`: Service implementations for each protocol
- `layer`: Layer abstractions and source management
- `imagery`: Image processing and tile manipulation
- `terrain`: Terrain and DEM tile handling
- `vector`: Vector tile processing
- `sources`: Source implementations (WMS, ArcGIS, Mapbox, etc.)
- `request`: Request parsing and routing
- `imports`: Import handlers (MBTiles, GeoPackage, archives)
- `exports`: Export handlers (MBTiles, GeoPackage, COG)
- `setting`: Configuration and settings management
- `tile`: Tile definitions and options
- `utils`: Utility functions

## Configuration

The proxy uses a configuration-based approach where services, sources, caches, and grids are defined through settings. Each service can have:

- Multiple data sources (WMS, tile servers, etc.)
- Cache configurations with different layouts
- Grid definitions for projections and tile matrices
- Legend and feature info support where applicable

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Contributing

1. Fork the repository
2. Create your feature branch
3. Commit your changes
4. Push to the branch
5. Create a Pull Request

Please ensure:
- Code follows the project's style guidelines
- All tests pass
- New features include tests
- Commits are clear and descriptive

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	setting.ProxyInstance
	Id            string
	Type          ServiceType
	Service       service.Service
	Grids         map[string]geo.Grid
	Sources       map[string]layer.Layer
	InfoSources   map[string]layer.InfoLayer
	LegendSources map[string]layer.LegendLayer
	Caches        map[string]cache.Manager
	// contains filtered or unexported fields
}

func NewService

func NewService(dataset *setting.ProxyService, globals *setting.GlobalsSetting, fac setting.CacheFactory) *Service

func (*Service) Clean

func (s *Service) Clean()

func (*Service) GetCache

func (s *Service) GetCache(name string) cache.Manager

func (*Service) GetCacheSource

func (s *Service) GetCacheSource(name string, opt tile.TileOptions) layer.Layer

func (*Service) GetGrid

func (s *Service) GetGrid(name string) geo.Grid

func (*Service) GetId

func (s *Service) GetId() string

func (*Service) GetInfoSource

func (s *Service) GetInfoSource(name string) layer.InfoLayer

func (*Service) GetLegendSource

func (s *Service) GetLegendSource(name string) layer.LegendLayer

func (*Service) GetService

func (s *Service) GetService() service.Service

func (*Service) GetServiceType

func (s *Service) GetServiceType() ServiceType

func (*Service) GetSource

func (s *Service) GetSource(name string) layer.Layer

func (*Service) Reload

func (s *Service) Reload(newConfig *setting.ProxyService, globals *setting.GlobalsSetting, fac setting.CacheFactory) error

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServiceType

type ServiceType uint32
const (
	MapboxService ServiceType = 0
	WMSService    ServiceType = 1
	WMTSService   ServiceType = 2
	TileService   ServiceType = 3
	CesiumService ServiceType = 4
)

type TileProxy

type TileProxy struct {
	Services map[string]*Service
	// contains filtered or unexported fields
}

func NewTileProxy

func NewTileProxy(globals *setting.GlobalsSetting, proxys []*setting.ProxyService, fac setting.CacheFactory) *TileProxy

func (*TileProxy) Reload

func (t *TileProxy) Reload(proxy []*setting.ProxyService, fac setting.CacheFactory)

func (*TileProxy) RemoveService

func (t *TileProxy) RemoveService(id string)

func (*TileProxy) ServeHTTP

func (s *TileProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*TileProxy) UpdateService

func (t *TileProxy) UpdateService(id string, d *setting.ProxyService, fac setting.CacheFactory)

Directories

Path Synopsis
amap command
arcgisonline command
baidu command
bingmap command
cesium command
google command
luokuang command
mapbox command
osm command
tianditu command
wms command
wmts command
ray

Jump to

Keyboard shortcuts

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