https://github.com/hackergrrl/geojson-linestring-dissolve
Dissolve connected GeoJSON LineStrings into a single LineString.
https://github.com/hackergrrl/geojson-linestring-dissolve
Last synced: 3 months ago
JSON representation
Dissolve connected GeoJSON LineStrings into a single LineString.
- Host: GitHub
- URL: https://github.com/hackergrrl/geojson-linestring-dissolve
- Owner: hackergrrl
- Created: 2017-01-30T23:03:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-30T23:10:01.000Z (over 8 years ago)
- Last Synced: 2025-02-18T17:28:23.005Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# geojson-linestring-dissolve
> Dissolve connected GeoJSON LineStrings into a single LineString.
## Usage
```js
var dissolve = require('geojson-linestring-dissolve')var line1 = {
type: 'LineString',
coordinates: [
[0.0, 0.0],
[1.0, 1.0],
[2.0, 2.0]
]
}var line2 = {
type: 'LineString',
coordinates: [
[2.0, 2.0],
[3.0, 3.0]
]
}console.log(dissolve([line1, line2]))
```outputs
```
{
type: 'LineString',
coordinates: [
[0.0, 0.0],
[1.0, 1.0],
[2.0, 2.0],
[3.0, 3.0]
]
}
```## API
```js
var dissolve = require('geojson-linestring-dissolve')
```### dissolve([lineStrings])
Consumes an array of [GeoJSON](http://geojson.org/geojson-spec.html)
`LineString`s, and returns a new GeoJSON `LineString` object, with all touching
`LineString`s dissolved into a single unit. If the `LineString`s are
non-contiguous, a `MultiLineString` is returned.## Install
With [npm](https://npmjs.org/) installed, run
```
$ npm install geojson-linestring-dissolve
```## Caveats
There are some cases that this module does not *yet* handle:
1. `LineString`s that fork or junction are returned as two separate
`LineString`s -- one fork is chosen at random.
2. Forks or junctions are only detected if they occur at the `LineString`'s head
or tail coordinate.See a use case that you know how to fill in? PRs welcome!
## License
ISC