@turf/difference
Advanced tools
Comparing version 6.2.0-alpha.1 to 6.2.0-alpha.2
@@ -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; |
{ | ||
"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" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
13323
7
256
+ Addedpolygon-clipping@^0.14.3
+ Addedpolygon-clipping@0.14.3(transitive)
+ Addedsplaytree@3.1.2(transitive)
- Removed@turf/area@^6.2.0-alpha.1
- Removed@turf/meta@^6.2.0-alpha.1
- Removedmartinez-polygon-clipping@^0.6.2
- Removed@turf/area@6.5.0(transitive)
- Removed@turf/meta@6.5.0(transitive)
- Removedmartinez-polygon-clipping@0.6.2(transitive)
- Removedrobust-predicates@2.0.4(transitive)
- Removedsplaytree@0.1.4(transitive)
- Removedtinyqueue@1.2.3(transitive)
Updated@turf/helpers@^6.2.0-alpha.2