Documentation ¶
Overview ¶
Package simplify implements several reducing/simplifying functions for `orb.Geometry` types.
Index ¶
- type DouglasPeuckerSimplifier
- func (s *DouglasPeuckerSimplifier) Collection(c orb.Collection) orb.Collection
- func (s *DouglasPeuckerSimplifier) LineString(ls orb.LineString) orb.LineString
- func (s *DouglasPeuckerSimplifier) MultiLineString(mls orb.MultiLineString) orb.MultiLineString
- func (s *DouglasPeuckerSimplifier) MultiPolygon(mp orb.MultiPolygon) orb.MultiPolygon
- func (s *DouglasPeuckerSimplifier) Polygon(p orb.Polygon) orb.Polygon
- func (s *DouglasPeuckerSimplifier) Ring(r orb.Ring) orb.Ring
- func (s *DouglasPeuckerSimplifier) Simplify(g orb.Geometry) orb.Geometry
- type RadialSimplifier
- func (s *RadialSimplifier) Collection(c orb.Collection) orb.Collection
- func (s *RadialSimplifier) LineString(ls orb.LineString) orb.LineString
- func (s *RadialSimplifier) MultiLineString(mls orb.MultiLineString) orb.MultiLineString
- func (s *RadialSimplifier) MultiPolygon(mp orb.MultiPolygon) orb.MultiPolygon
- func (s *RadialSimplifier) Polygon(p orb.Polygon) orb.Polygon
- func (s *RadialSimplifier) Ring(r orb.Ring) orb.Ring
- func (s *RadialSimplifier) Simplify(g orb.Geometry) orb.Geometry
- type VisvalingamSimplifier
- func (s *VisvalingamSimplifier) Collection(c orb.Collection) orb.Collection
- func (s *VisvalingamSimplifier) LineString(ls orb.LineString) orb.LineString
- func (s *VisvalingamSimplifier) MultiLineString(mls orb.MultiLineString) orb.MultiLineString
- func (s *VisvalingamSimplifier) MultiPolygon(mp orb.MultiPolygon) orb.MultiPolygon
- func (s *VisvalingamSimplifier) Polygon(p orb.Polygon) orb.Polygon
- func (s *VisvalingamSimplifier) Ring(r orb.Ring) orb.Ring
- func (s *VisvalingamSimplifier) Simplify(g orb.Geometry) orb.Geometry
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DouglasPeuckerSimplifier ¶
type DouglasPeuckerSimplifier struct {
Threshold float64
}
A DouglasPeuckerSimplifier wraps the DouglasPeucker function.
Example ¶
package main import ( "fmt" "github.com/paulmach/orb" "github.com/paulmach/orb/simplify" ) func main() { // + // \ // \ // + // \ // \ // +-----+ original := orb.LineString{{0, 0}, {2, 0}, {1, 1}, {0, 2}} // low threshold just removes the colinear point reduced := simplify.DouglasPeucker(0.0).Simplify(original.Clone()) fmt.Println(reduced) // high threshold just leaves start and end reduced = simplify.DouglasPeucker(2).Simplify(original) fmt.Println(reduced) }
Output: [[0 0] [2 0] [0 2]] [[0 0] [0 2]]
func DouglasPeucker ¶
func DouglasPeucker(threshold float64) *DouglasPeuckerSimplifier
DouglasPeucker creates a new DouglasPeuckerSimplifier.
func (*DouglasPeuckerSimplifier) Collection ¶
func (s *DouglasPeuckerSimplifier) Collection(c orb.Collection) orb.Collection
Collection will simplify the collection using this simplifier.
func (*DouglasPeuckerSimplifier) LineString ¶
func (s *DouglasPeuckerSimplifier) LineString(ls orb.LineString) orb.LineString
LineString will simplify the linestring using this simplifier.
func (*DouglasPeuckerSimplifier) MultiLineString ¶
func (s *DouglasPeuckerSimplifier) MultiLineString(mls orb.MultiLineString) orb.MultiLineString
MultiLineString will simplify the multi-linestring using this simplifier.
func (*DouglasPeuckerSimplifier) MultiPolygon ¶
func (s *DouglasPeuckerSimplifier) MultiPolygon(mp orb.MultiPolygon) orb.MultiPolygon
MultiPolygon will simplify the multi-polygon using this simplifier.
func (*DouglasPeuckerSimplifier) Polygon ¶
func (s *DouglasPeuckerSimplifier) Polygon(p orb.Polygon) orb.Polygon
Polygon will simplify the polygon using this simplifier.
type RadialSimplifier ¶
type RadialSimplifier struct { DistanceFunc orb.DistanceFunc Threshold float64 // euclidean distance }
A RadialSimplifier wraps the Radial functions
Example ¶
package main import ( "fmt" "github.com/paulmach/orb" "github.com/paulmach/orb/planar" "github.com/paulmach/orb/simplify" ) func main() { // + // \ // \ // + // | // +--+ original := orb.LineString{{0, 0}, {1, 0}, {1, 1}, {0, 2}} // will remove the points within 1.0 of the previous point // in this case just the second point reduced := simplify.Radial(planar.Distance, 1.0).Simplify(original.Clone()) fmt.Println(reduced) // will remove the 2nd and 3rd point since it's within 1.5 or the first point. reduced = simplify.Radial(planar.Distance, 1.5).Simplify(original) fmt.Println(reduced) }
Output:
func Radial ¶
func Radial(df orb.DistanceFunc, threshold float64) *RadialSimplifier
Radial creates a new RadialSimplifier.
func (*RadialSimplifier) Collection ¶
func (s *RadialSimplifier) Collection(c orb.Collection) orb.Collection
Collection will simplify the collection using this simplifier.
func (*RadialSimplifier) LineString ¶
func (s *RadialSimplifier) LineString(ls orb.LineString) orb.LineString
LineString will simplify the linestring using this simplifier.
func (*RadialSimplifier) MultiLineString ¶
func (s *RadialSimplifier) MultiLineString(mls orb.MultiLineString) orb.MultiLineString
MultiLineString will simplify the multi-linestring using this simplifier.
func (*RadialSimplifier) MultiPolygon ¶
func (s *RadialSimplifier) MultiPolygon(mp orb.MultiPolygon) orb.MultiPolygon
MultiPolygon will simplify the multi-polygon using this simplifier.
func (*RadialSimplifier) Polygon ¶
func (s *RadialSimplifier) Polygon(p orb.Polygon) orb.Polygon
Polygon will simplify the polygon using this simplifier.
type VisvalingamSimplifier ¶
A VisvalingamSimplifier is a reducer that performs the vivalingham algorithm.
func Visvalingam ¶
func Visvalingam(threshold float64, minPointsToKeep int) *VisvalingamSimplifier
Visvalingam creates a new VisvalingamSimplifier.
func VisvalingamKeep ¶
func VisvalingamKeep(toKeep int) *VisvalingamSimplifier
VisvalingamKeep runs the Visvalingam-Whyatt algorithm removing triangles of minimum area until we're down to `toKeep` number of points.
func VisvalingamThreshold ¶
func VisvalingamThreshold(threshold float64) *VisvalingamSimplifier
VisvalingamThreshold runs the Visvalingam-Whyatt algorithm removing triangles whose area is below the threshold.
func (*VisvalingamSimplifier) Collection ¶
func (s *VisvalingamSimplifier) Collection(c orb.Collection) orb.Collection
Collection will simplify the collection using this simplifier.
func (*VisvalingamSimplifier) LineString ¶
func (s *VisvalingamSimplifier) LineString(ls orb.LineString) orb.LineString
LineString will simplify the linestring using this simplifier.
func (*VisvalingamSimplifier) MultiLineString ¶
func (s *VisvalingamSimplifier) MultiLineString(mls orb.MultiLineString) orb.MultiLineString
MultiLineString will simplify the multi-linestring using this simplifier.
func (*VisvalingamSimplifier) MultiPolygon ¶
func (s *VisvalingamSimplifier) MultiPolygon(mp orb.MultiPolygon) orb.MultiPolygon
MultiPolygon will simplify the multi-polygon using this simplifier.
func (*VisvalingamSimplifier) Polygon ¶
func (s *VisvalingamSimplifier) Polygon(p orb.Polygon) orb.Polygon
Polygon will simplify the polygon using this simplifier.