tile38/internal/clip/rect.go

18 lines
422 B
Go
Raw Normal View History

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)
}
2018-10-22 05:08:56 +03:00
poly := geometry.NewPoly(points, nil, nil)
gPoly := geojson.NewPolygon(poly)
return Clip(gPoly, clipper)
}