simplify-path

WebJar for simplify-path

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

simplify-path
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

simplify-path
WebJar for simplify-path
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mattdesl/simplify-path

Download simplify-path

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/simplify-path/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>simplify-path</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/simplify-path/
implementation 'org.webjars.npm:simplify-path:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/simplify-path/
implementation ("org.webjars.npm:simplify-path:1.1.0")
'org.webjars.npm:simplify-path:jar:1.1.0'
<dependency org="org.webjars.npm" name="simplify-path" rev="1.1.0">
  <artifact name="simplify-path" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='simplify-path', version='1.1.0')
)
libraryDependencies += "org.webjars.npm" % "simplify-path" % "1.1.0"
[org.webjars.npm/simplify-path "1.1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

simplify-path

stable

Simplifies a 2D polyline, first using a radial distance check, and then a recursive Douglas-Peucker algorithm. The code is from simplify-js, but uses arrays for better interoperability with npm modules like stack.gl, parse-svg-path, chaikin-smooth, ndarray, etc.

var simplify = require('simplify-path')

//our input polyline
var path = [ [250, 150], [250, 150], [25, 25], [24, 25], [10, 10] ]
var tolerance = 10

//result
path = simplify(path, tolerance)

Result:

[ [ 250, 150 ], [ 25, 25 ], [ 10, 10 ] ]

Or you can use the algorithms individually:

var path2 = simplify.radialDistance(path, tolerance)
var path3 = simplify.douglasPeucker(path, tolerance)

You can also require each algorithm separately:

var simplify1 = require('simplify-path/radial-distance')
var simplify2 = require('simplify-path/douglas-peucker')

Note: For performance, this does not produce a deep copy of the input.

Usage

NPM

simplify(path, tolerance)

Simplifies the input path with the specified tolerance, removing redundant points first using radial distance, then Douglas-Peucker algorithm. Returns an array of simplified points.

simplify.radialDistance(path, tolerance)

Like above, but using only the Radial Distance algorithm.

simplify.douglasPeucker(path, tolerance)

Like above, but using only the Douglas-Peucker algorithm.

License

MIT, see LICENSE.md for details.

Versions

Version
1.1.0