Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Latest commit

 

History

History
 
 

simplify

orb/simplify Godoc Reference

This package implements several reducing/simplifing function for orb.Geometry types.

Currently implemented:

Note: The geometry object CAN be modified, use Clone() if a copy is required.

Douglas-Peucker

Probably the most popular simplification algorithm. For algorithm details, see wikipedia.

The algorithm is a pass through for 1d geometry, e.g. Point and MultiPoint. The algorithms can modify the original geometry, use Clone() if a copy is required.

Usage:

original := orb.LineString{}
reduced := simplify.DouglasPeucker(threshold).Simplify(original.Clone())

Visvalingam

See Mike Bostock's explanation for algorithm details.

The algorithm is a pass through for 1d geometry, e.g. Point and MultiPoint. The algorithms can modify the original geometry, use Clone() if a copy is required.

Usage:

original := orb.Ring{}

// will remove all whose triangle is smaller than `threshold`
reduced := simplify.VisvalingamThreshold(threshold).Simplify(original)

// will remove points until there are only `toKeep` points left.
reduced := simplify.VisvalingamKeep(toKeep).Simplify(original)

// One can also combine the parameters.
// This will continue to remove points until:
//  - there are no more below the threshold,
//  - or the new path is of length `toKeep`
reduced := simplify.Visvalingam(threshold, toKeep).Simplify(original)

Radial

Radial reduces the path by removing points that are close together. A full algorithm description.

The algorithm is a pass through for 1d geometry, like Point and MultiPoint. The algorithms can modify the original geometry, use Clone() if a copy is required.

Usage:

original := geo.Polygon{}

// this method uses a Euclidean distance measure.
reduced := simplify.Radial(planar.Distance, threshold).Simplify(path)

// if the points are in the lng/lat space Radial Geo will
// compute the geo distance between the coordinates.
reduced:= simplify.Radial(geo.Distance, meters).Simplify(path)