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

# README

orb/clip Godoc Reference

Package orb/clip provides functions for clipping lines and polygons to a bounding box.

Example

bound := orb.Bound{Min: orb.Point{0, 0}, Max: orb.Point{30, 30}}

ls := orb.LineString{
    {-10, 10}, {10, 10}, {10, -10}, {20, -10}, {20, 10},
    {40, 10}, {40, 20}, {20, 20}, {20, 40}, {10, 40},
    {10, 20}, {5, 20}, {-10, 20},
}

// works on and returns an orb.Geometry interface.
clipped = clip.Geometry(bound, ls)

// or clip the line string directly
clipped = clip.LineString(bound, ls)

List of sub-package utilities

Acknowledgements

This library is based on mapbox/lineclip.

# Packages

Package smartclip performs a more advanced clipping algorithm so it can deal with correctly oriented open rings and polygon.

# Functions

Bound intersects the two bounds.
Collection clips each element in the collection to the bounding box.
Geometry will clip the geometry to the bounding box using the correct functions for the type.
LineString clips the linestring to the bounding box.
MultiLineString clips the linestrings to the bounding box and returns a linestring union.
MultiPoint returns a new set with the points outside the bound removed.
MultiPolygon clips the multi polygon to the bounding box excluding any polygons if they don't intersect the bounding box.
OpenBound is an option to treat the bound as open.
Polygon clips the polygon to the bounding box excluding the inner rings if they do not intersect the bounding box.
Ring clips the ring to the bounding box and returns another ring.

# Type aliases

An Option is a possible parameter to the clip operations.