Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including line-simplify-rdp with all npm packages installed. Try it out:

var lineSimplifyRdp = require("line-simplify-rdp")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

line-simplify-rdp v0.4.0

Simplify lines using the Ramer–Douglas–Peucker algorithm

line-simplify-rdp

Simplify polylines and polygons using the Ramer–Douglas–Peucker algorithm.

API

line-simplify-rdp

simplify(points, threshold, closed) ⇒ array

Return a simplified version of the polyline or polygon defined by the given points. Basically what happens is that some points are removed from the line, but only ones that leave the resulting line within a certain distance of the original.

Kind: Exported function
Returns: array - the simplified points. (This will always be separately allocated object, not the one passed in, but it will contain the same point objects passed in.)

ParamTypeDescription
pointsarraypolyline or polygon. Each element of the array must be an object with at least x and y numeric properties. Neither the array nor any member will be modified.
thresholdnumbermaximum distance the simplified line can be from the original. Should be grater than or equal to zero. Passing zero means only colinear points will be eliminated; greater values lead to more aggressive line approximations.
closedbooleanif the passed first point and the last points are the same, this flag does nothing. Otherwise, if closed is true, the points will be treated as a polygon with an implied last segment between the last point and the first point.

License

MIT

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free