Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rowanwins/polyline-splitter

A small (<10kb minified) javascript library for splitting geojson polylines by other polylines.
https://github.com/rowanwins/polyline-splitter

Last synced: 28 days ago
JSON representation

A small (<10kb minified) javascript library for splitting geojson polylines by other polylines.

Awesome Lists containing this project

README

        

## polyline-splitter
A small (<10kb minified) javascript library for splitting geojson polylines by other polylines.

### Install
````
npm install polyline-splitter
````

### API
Accepts either a geojson `Feature` or ` LineString | MultiLineString`.

Returns a `MultiLineString` containing the joined lines.
If no intersection points are found returns the first argument.

```js
import polylineSplitter from 'polyline-splitter'
// or
const polylineSplitter = require('polyline-splitter')

const line1 = {
"type": "LineString",
"coordinates": [[0, 0],[10, 0]]
}

const line2 = {
"type": "LineString",
"coordinates": [[5, -10],[5, 10]]
}
const output = polylineSplitter(line1, line2)
// => {
// "type":"MultiLineString",
// "coordinates":[
// [[0,0], [5,0]],
// [[5,0], [10,0]],
// [[5,-10], [5,0]],
// [[5,0], [5,10]]
// ]
// }
```