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

@turf/difference

Package Overview
Dependencies
Maintainers
6
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/difference - npm Package Compare versions

Comparing version 6.2.0-alpha.1 to 6.2.0-alpha.2

35

dist/es/index.js

@@ -1,6 +0,4 @@

import { diff } from 'martinez-polygon-clipping';
import area from '@turf/area';
import { feature, multiPolygon, polygon } from '@turf/helpers';
import polygonClipping from 'polygon-clipping';
import { polygon, multiPolygon } from '@turf/helpers';
import { getGeom } from '@turf/invariant';
import { flattenEach } from '@turf/meta';

@@ -46,9 +44,3 @@ /**

// Issue #721 - JSTS/Martinez can't handle empty polygons
geom1 = removeEmptyPolygon(geom1);
geom2 = removeEmptyPolygon(geom2);
if (!geom1) return null;
if (!geom2) return feature(geom1, properties);
var differenced = diff(geom1.coordinates, geom2.coordinates);
var differenced = polygonClipping.difference(geom1.coordinates, geom2.coordinates);
if (differenced.length === 0) return null;

@@ -59,23 +51,2 @@ if (differenced.length === 1) return polygon(differenced[0], properties);

/**
* Detect Empty Polygon
*
* @private
* @param {Geometry<Polygon|MultiPolygon>} geom Geometry Object
* @returns {Geometry<Polygon|MultiPolygon>|null} removed any polygons with no areas
*/
function removeEmptyPolygon(geom) {
switch (geom.type) {
case 'Polygon':
if (area(geom) > 1) return geom;
return null;
case 'MultiPolygon':
var coordinates = [];
flattenEach(geom, function (feature$$1) {
if (area(feature$$1) > 1) coordinates.push(feature$$1.geometry.coordinates);
});
if (coordinates.length) return {type: 'MultiPolygon', coordinates: coordinates};
}
}
export default difference;

@@ -5,7 +5,5 @@ 'use strict';

var martinez = require('martinez-polygon-clipping');
var area = _interopDefault(require('@turf/area'));
var polygonClipping = _interopDefault(require('polygon-clipping'));
var helpers = require('@turf/helpers');
var invariant = require('@turf/invariant');
var meta = require('@turf/meta');

@@ -51,9 +49,3 @@ /**

// Issue #721 - JSTS/Martinez can't handle empty polygons
geom1 = removeEmptyPolygon(geom1);
geom2 = removeEmptyPolygon(geom2);
if (!geom1) return null;
if (!geom2) return helpers.feature(geom1, properties);
var differenced = martinez.diff(geom1.coordinates, geom2.coordinates);
var differenced = polygonClipping.difference(geom1.coordinates, geom2.coordinates);
if (differenced.length === 0) return null;

@@ -64,24 +56,3 @@ if (differenced.length === 1) return helpers.polygon(differenced[0], properties);

/**
* Detect Empty Polygon
*
* @private
* @param {Geometry<Polygon|MultiPolygon>} geom Geometry Object
* @returns {Geometry<Polygon|MultiPolygon>|null} removed any polygons with no areas
*/
function removeEmptyPolygon(geom) {
switch (geom.type) {
case 'Polygon':
if (area(geom) > 1) return geom;
return null;
case 'MultiPolygon':
var coordinates = [];
meta.flattenEach(geom, function (feature) {
if (area(feature) > 1) coordinates.push(feature.geometry.coordinates);
});
if (coordinates.length) return {type: 'MultiPolygon', coordinates: coordinates};
}
}
module.exports = difference;
module.exports.default = difference;

13

package.json
{
"name": "@turf/difference",
"version": "6.2.0-alpha.1",
"version": "6.2.0-alpha.2",
"description": "turf difference module",

@@ -43,2 +43,3 @@ "author": "Turf Authors",

"load-json-file": "*",
"npm-run-all": "*",
"rollup": "*",

@@ -49,9 +50,7 @@ "tape": "*",

"dependencies": {
"@turf/area": "^6.2.0-alpha.1",
"@turf/helpers": "^6.2.0-alpha.1",
"@turf/invariant": "^6.2.0-alpha.1",
"@turf/meta": "^6.2.0-alpha.1",
"martinez-polygon-clipping": "^0.6.2"
"@turf/helpers": "^6.2.0-alpha.2",
"@turf/invariant": "^6.2.0-alpha.2",
"polygon-clipping": "^0.14.3"
},
"gitHead": "fc519c045a8931c1e14eab9160a7e28391f8da02"
"gitHead": "23d5cb91d77e0c1e2e903a2252f525797f1d0d09"
}
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