Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/union

Package Overview
Dependencies
Maintainers
4
Versions
60
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 5.1.5 to 6.0.0

index.ts

45

index.js

@@ -1,8 +0,14 @@

import { GeoJSONReader, GeoJSONWriter, UnionOp } from 'turf-jsts';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var martinez = require("martinez-polygon-clipping");
var invariant_1 = require("@turf/invariant");
var helpers_1 = require("@turf/helpers");
/**
* Takes two or more {@link Polygon|polygons} and returns a combined polygon. If the input polygons are not contiguous, this function returns a {@link MultiPolygon} feature.
* Takes two {@link (Multi)Polygon(s)} and returns a combined polygon. If the input polygons are not contiguous, this function returns a {@link MultiPolygon} feature.
*
* @name union
* @param {...Feature<Polygon>} A polygon to combine
* @param {Feature<Polygon|MultiPolygon>} polygon1 input Polygon feature
* @param {Feature<Polygon|MultiPolygon>} polygon2 Polygon feature to difference from polygon1
* @param {Object} [options={}] Optional Parameters
* @param {Object} [options.properties={}] Translate Properties to output Feature
* @returns {Feature<(Polygon|MultiPolygon)>} a combined {@link Polygon} or {@link MultiPolygon} feature

@@ -30,20 +36,15 @@ * @example

*/
function union() {
var reader = new GeoJSONReader();
var result = reader.read(JSON.stringify(arguments[0].geometry));
for (var i = 1; i < arguments.length; i++) {
result = UnionOp.union(result, reader.read(JSON.stringify(arguments[i].geometry)));
}
var writer = new GeoJSONWriter();
result = writer.write(result);
return {
type: 'Feature',
geometry: result,
properties: arguments[0].properties
};
function union(polygon1, polygon2, options) {
if (options === void 0) { options = {}; }
var coords1 = invariant_1.getGeom(polygon1).coordinates;
var coords2 = invariant_1.getGeom(polygon2).coordinates;
var unioned = martinez.union(coords1, coords2);
console.log(unioned);
if (unioned.length === 0)
return null;
if (unioned.length === 1)
return helpers_1.polygon(unioned[0], options.properties);
else
return helpers_1.multiPolygon(unioned, options.properties);
}
export default union;
exports.default = union;
{
"name": "@turf/union",
"version": "5.1.5",
"version": "6.0.0",
"description": "turf union module",
"main": "main.js",
"module": "main.es.js",
"types": "index.d.ts",
"main": "index",
"files": [
"index.js",
"index.d.ts",
"main.js",
"main.es.js"
"index.ts"
],
"scripts": {
"pretest": "rollup -c ../../rollup.config.js",
"test": "node -r @std/esm test.js",
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js",
"bench": "node -r @std/esm bench.js",
"pretest": "tsc",
"test": "node test.js",
"bench": "node bench.js",
"docs": "node ../../scripts/generate-readmes"

@@ -36,18 +31,15 @@ },

"devDependencies": {
"@std/esm": "*",
"benchmark": "*",
"glob": "*",
"load-json-file": "*",
"rollup": "*",
"typescript": "*",
"tape": "*",
"write-json-file": "*"
"write-json-file": "*",
"@turf/combine": "*"
},
"dependencies": {
"@turf/helpers": "^5.1.5",
"turf-jsts": "*"
},
"@std/esm": {
"esm": "js",
"cjs": true
"@turf/helpers": "6.x",
"@turf/invariant": "6.x",
"martinez-polygon-clipping": "*"
}
}

@@ -7,7 +7,8 @@ # @turf/union

Takes two or more [polygons](https://tools.ietf.org/html/rfc7946#section-3.1.6) and returns a combined polygon. If the input polygons are not contiguous, this function returns a [MultiPolygon](https://tools.ietf.org/html/rfc7946#section-3.1.7) feature.
Takes two or more [(Multi)Polygon(s)](https://tools.ietf.org/html/rfc7946#section-3.1.6) and returns a combined polygon. If the input polygons are not contiguous, this function returns a [MultiPolygon](https://tools.ietf.org/html/rfc7946#section-3.1.7) feature.
**Parameters**
- `A` **...[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)&lt;[Polygon](https://tools.ietf.org/html/rfc7946#section-3.1.6)>** polygon to combine
- `polygon1` **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)&lt;([Polygon](https://tools.ietf.org/html/rfc7946#section-3.1.6) \| [MultiPolygon](https://tools.ietf.org/html/rfc7946#section-3.1.7))>** input Polygon feature
- `polygon2` **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)&lt;([Polygon](https://tools.ietf.org/html/rfc7946#section-3.1.6) \| [MultiPolygon](https://tools.ietf.org/html/rfc7946#section-3.1.7))>** Polygon feature to difference from polygon1

@@ -14,0 +15,0 @@ **Examples**

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