Socket
Socket
Sign inDemoInstall

turf-union

Package Overview
Dependencies
Maintainers
8
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-union - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

test/fixtures/in/Intersect1.geojson

52

index.js

@@ -8,2 +8,54 @@ // look here for help http://svn.osgeo.org/grass/grass/branches/releasebranch_6_4/vector/v.overlay/main.c

/**
* Takes two {@link Polygon} features and returnes a combined {@link Polygon} feature. If the input Polygon features are not contiguous, this function returns a {@link MultiPolygon} feature.
*
* @module turf/union
* @category transformation
* @param {Polygon} poly1 an input Polygon
* @param {Polygon} poly2 another input Polygon
* @return {Feature} a combined {@link Polygon} or {@link MultiPolygon} feature
* @example
* var poly1 = {
* "type": "Feature",
* "properties": {
* "fill": "#0f0"
* },
* "geometry": {
* "type": "Polygon",
* "coordinates": [[
* [-82.574787, 35.594087],
* [-82.574787, 35.615581],
* [-82.545261, 35.615581],
* [-82.545261, 35.594087],
* [-82.574787, 35.594087]
* ]]
* }
* };
* var poly2 = {
* "type": "Feature",
* "properties": {
* "fill": "#00f"
* },
* "geometry": {
* "type": "Polygon",
* "coordinates": [[
* [-82.560024, 35.585153],
* [-82.560024, 35.602602],
* [-82.52964, 35.602602],
* [-82.52964, 35.585153],
* [-82.560024, 35.585153]
* ]]
* }
* };
* var polygons = {
* "type": "FeatureCollection",
* "features": [poly1, poly2]
* };
*
* var union = turf.union(poly1, poly2);
*
* //=polygons
*
* //=union
*/
module.exports = function(poly1, poly2){

@@ -10,0 +62,0 @@ var reader = new jsts.io.GeoJSONReader();

11

package.json
{
"name": "turf-union",
"version": "1.0.0",
"version": "1.0.1",
"description": "find the union of geographic features",
"main": "index.js",
"scripts": {
"test": "tape test/*.js"
"test": "tape test/*.js",
"doc": "dox -r < index.js | doxme --readme > README.md"
},

@@ -25,4 +26,6 @@ "repository": {

"benchmark": "^1.0.0",
"glob": "~4.3.1",
"tape": "~3.0.3"
"glob": "~4.3.5",
"tape": "~3.5.0",
"dox": "^0.6.1",
"doxme": "^1.4.3"
},

@@ -29,0 +32,0 @@ "dependencies": {

@@ -1,36 +0,62 @@

turf-union
===
# turf-union
[![build status](https://secure.travis-ci.org/Turfjs/turf-union.png)](http://travis-ci.org/Turfjs/turf-union)
Combines two polygons into one.
find the union of geographic features
###Install
```sh
npm install turf-union
```
### `turf.union(poly1, poly2)`
###Parameters
Takes two polygons and combines them into one polgyon.
name|description
---|---
polygon1|subject polygon
polygon2|polygon to add
###Usage
### Parameters
| parameter | type | description |
| --------- | ------- | --------------------- |
| `poly1` | Polygon | an input Polygon |
| `poly2` | Polygon | another input Polygon |
### Example
```js
union(polygon1, polygon2)
var poly1 = turf.polygon([[
[-82.574787, 35.594087],
[-82.574787, 35.615581],
[-82.545261, 35.615581],
[-82.545261, 35.594087],
[-82.574787, 35.594087]
]]);
poly1.properties.fill = '#0f0';
var poly2 = turf.polygon([[
[-82.560024, 35.585153],
[-82.560024, 35.602602],
[-82.52964, 35.602602],
[-82.52964, 35.585153],
[-82.560024, 35.585153]
]]);
poly2.properties.fill = '#00f';
var polyFC = turf.featurecollection([poly1, poly2]);
var union = turf.union(poly1, poly2);
//=polyFC
//=union
```
###Example
## Installation
```js
var union = require('turf-union')
var fs = require('fs')
Requires [nodejs](http://nodejs.org/).
var poly1 = JSON.parse(fs.readFileSync('/path/to/file1.geojson'))
var poly2 = JSON.parse(fs.readFileSync('/path/to/file2.geojson'))
```sh
$ npm install turf-union
```
var unioned = union(poly1, poly2)
## Tests
```sh
$ npm test
```

@@ -9,3 +9,3 @@ var union = require('../'),

test('union', function(t){
glob.sync(__dirname + '/fixtures/in/*.json').forEach(function(input) {
glob.sync(__dirname + '/fixtures/in/*.geojson').forEach(function(input) {
var fcs = JSON.parse(fs.readFileSync(input));

@@ -17,2 +17,2 @@ var output = union(fcs[0].features[0], fcs[1].features[0]);

t.end();
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc