package
0.11.1
Repository: https://github.com/paulmach/orb.git
Documentation: pkg.go.dev

# README

orb/clip/smartclip Godoc Reference

This package extends the clip functionality to handle partial 2d geometries. The input polygon rings need to only intersect the bound. The algorithm will use that, plus the orientation, to wrap/close the rings around the edge of the bound.

The use case is OSM multipolyon relations where a ring (inner or outer) contains multiple ways but only one is in the current viewport. With only the ways intersecting the viewport and their orientation the correct shape can be drawn.

Example

bound := orb.Bound{Min: orb.Point{1, 1}, Max: orb.Point{10, 10}}

// a partial ring cutting the bound down the middle.
ring := orb.Ring{{0, 0}, {11, 11}}
clipped := smartclip.Ring(bound, ring, orb.CCW)

// clipped is a multipolyon with one ring that wraps counter-clockwise
// around the top triangle of the box
// [[[[1 1] [10 10] [5.5 10] [1 10] [1 5.5] [1 1]]]]

# Functions

Geometry will do a smart more involved clipping and wrapping of the geometry.
MultiPolygon will smart clip a multipolygon to the bound.
Polygon will smart clip a polygon to the bound.
Ring will smart clip a ring to the boundary.