forked from go-spatial/tegola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
57 lines (44 loc) · 1.26 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package test
import (
"context"
"github.com/go-spatial/geom"
"github.com/go-spatial/tegola"
"github.com/go-spatial/tegola/provider"
"github.com/go-spatial/tegola/dict"
)
const Name = "test"
var Count int
func init() {
provider.Register(Name, NewTileProvider, Cleanup)
}
// NewProvider setups a test provider. there are not currently any config params supported
func NewTileProvider(config dict.Dicter) (provider.Tiler, error) {
Count++
return &TileProvider{}, nil
}
// Cleanup cleans up all the test providers.
func Cleanup() { Count = 0 }
type TileProvider struct{}
func (tp *TileProvider) Layers() ([]provider.LayerInfo, error) {
return []provider.LayerInfo{
layer{
name: "test-layer",
geomType: geom.Polygon{},
srid: tegola.WebMercator,
},
}, nil
}
// TilFeatures always returns a feature with a polygon outlining the tile's Extent (not Buffered Extent)
func (tp *TileProvider) TileFeatures(ctx context.Context, layer string, t provider.Tile, fn func(f *provider.Feature) error) error {
// get tile bounding box
ext, srid := t.Extent()
debugTileOutline := provider.Feature{
ID: 0,
Geometry: ext.AsPolygon(),
SRID: srid,
Tags: map[string]interface{}{
"type": "debug_buffer_outline",
},
}
return fn(&debugTileOutline)
}