tile38/internal/clip/rect.go

18 lines
440 B
Go

package clip
import (
"github.com/tidwall/geojson"
"github.com/tidwall/geojson/geometry"
)
func clipRect(rect *geojson.Rect, clipper geojson.Object) geojson.Object {
base := rect.Base()
points := make([]geometry.Point, base.NumPoints())
for i := 0; i < len(points); i++ {
points[i] = base.PointAt(i)
}
poly := geometry.NewPoly(points, nil, geometry.DefaultIndex)
gPoly := geojson.NewPolygon(poly)
return Clip(gPoly, clipper)
}