https://github.com/dy/polyline-clean
Clean polygon or polyline coordinates: remove duplicates, degenerate, collinear or bad items, trim.
https://github.com/dy/polyline-clean
Last synced: about 1 year ago
JSON representation
Clean polygon or polyline coordinates: remove duplicates, degenerate, collinear or bad items, trim.
- Host: GitHub
- URL: https://github.com/dy/polyline-clean
- Owner: dy
- License: mit
- Created: 2018-04-26T02:22:12.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-27T00:57:31.000Z (about 8 years ago)
- Last Synced: 2025-04-14T23:53:46.121Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# polyline-clean [](http://github.com/badges/stability-badges) [](https://travis-ci.org/dy/polyline-clean)
Clean polyline or polygon data: remove duplicate, collinear, null points, etc.
[](https://npmjs.org/package/polyline-clean/)
```js
const c = require('polyline-clean')
// remove duplicate, degenerate or collinear segments
c([[0,0], [null,null], [1,1], [1,1], [.5,.5], [1,1], [3,3]])
// === [[0,0], [3,3]]
```
## `c(coordinates, options?)`
Return new coordinates array with bad points removed. If result is degenerate, `null` will be returned.
Option | Meaning
---|---
`ids` | Return indexes in the initial array instead of points.
`fold` | Collapse collinear segments. Can be a number indicating min angle threshold. `polygon` mode has more rigid folding. Useful to disable it when data has logarithmic fashion.
`polygon` | Apply polygon optimizations: remove coinciding end, collinear end segments, ignore degenerate results.
## Related
* [parse-poly](https://github.com/dy/parse-poly) − parse any polygon/polyline format and return list of coordinates.
* [simplify-path](https://www.npmjs.com/package/simplify-path) − simplify polyline with tolerance.
## License
(c) 2018 Dmitry Yv. MIT License