Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/rowanwins/polyline-splitter
- Owner: rowanwins
- License: mit
- Created: 2024-03-17T04:48:57.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-06-02T12:33:21.000Z (5 months ago)
- Last Synced: 2024-10-07T13:18:13.010Z (about 1 month ago)
- Language: TypeScript
- Size: 16.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: FUNDING.yml
- License: LICENSE
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]]
// ]
// }
```