forked from paulmach/orb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clip.go
30 lines (26 loc) · 765 Bytes
/
clip.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
package mvt
import (
"github.com/Smadarl/orb"
"github.com/Smadarl/orb/clip"
)
var (
// MapboxGLDefaultExtentBound holds the default mapbox vector tile bounds used by mapbox-gl.
// (https://www.mapbox.com/mapbox-gl-js/style-spec/#sources-vector)
MapboxGLDefaultExtentBound = orb.Bound{
Min: orb.Point{-1 * DefaultExtent, -1 * DefaultExtent},
Max: orb.Point{2*DefaultExtent - 1, 2*DefaultExtent - 1},
}
)
// Clip will clip all geometries in all layers to the given bounds.
func (ls Layers) Clip(box orb.Bound) {
for _, l := range ls {
l.Clip(box)
}
}
// Clip will clip all geometries in this layer to the given bounds.
func (l *Layer) Clip(box orb.Bound) {
for _, f := range l.Features {
g := clip.Geometry(box, f.Geometry)
f.Geometry = g
}
}