turf-difference
Advanced tools
Comparing version 2.0.0 to 3.0.0-canary.2f5f7167
63
index.js
@@ -8,3 +8,3 @@ // depend on jsts for now https://github.com/bjornharrtell/jsts/blob/master/examples/overlay.html | ||
* | ||
* @module turf/difference | ||
* @name difference | ||
* @category transformation | ||
@@ -61,38 +61,37 @@ * @param {Feature<Polygon>} poly1 input Polygon feaure | ||
module.exports = function(p1, p2) { | ||
var poly1 = JSON.parse(JSON.stringify(p1)); | ||
var poly2 = JSON.parse(JSON.stringify(p2)); | ||
if(poly1.type !== 'Feature') { | ||
poly1 = { | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: poly1 | ||
}; | ||
} | ||
if(poly2.type !== 'Feature') { | ||
poly2 = { | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: poly2 | ||
}; | ||
} | ||
module.exports = function (p1, p2) { | ||
var poly1 = JSON.parse(JSON.stringify(p1)); | ||
var poly2 = JSON.parse(JSON.stringify(p2)); | ||
if (poly1.type !== 'Feature') { | ||
poly1 = { | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: poly1 | ||
}; | ||
} | ||
if (poly2.type !== 'Feature') { | ||
poly2 = { | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: poly2 | ||
}; | ||
} | ||
var reader = new jsts.io.GeoJSONReader(); | ||
var a = reader.read(JSON.stringify(poly1.geometry)); | ||
var b = reader.read(JSON.stringify(poly2.geometry)); | ||
var differenced = a.difference(b); | ||
var parser = new jsts.io.GeoJSONParser(); | ||
differenced = parser.write(differenced); | ||
var reader = new jsts.io.GeoJSONReader(); | ||
var a = reader.read(JSON.stringify(poly1.geometry)); | ||
var b = reader.read(JSON.stringify(poly2.geometry)); | ||
var differenced = a.difference(b); | ||
poly1.geometry = differenced; | ||
if (differenced.isEmpty()) return undefined; | ||
if (poly1.geometry.type === 'GeometryCollection' && poly1.geometry.geometries.length === 0) { | ||
return undefined; | ||
} else { | ||
var writer = new jsts.io.GeoJSONWriter(); | ||
var geojsonGeometry = writer.write(differenced); | ||
poly1.geometry = differenced; | ||
return { | ||
type: 'Feature', | ||
properties: poly1.properties, | ||
geometry: differenced | ||
type: 'Feature', | ||
properties: poly1.properties, | ||
geometry: geojsonGeometry | ||
}; | ||
} | ||
}; |
{ | ||
"name": "turf-difference", | ||
"version": "2.0.0", | ||
"version": "3.0.0-canary.2f5f7167", | ||
"description": "[Turf](http://turfjs.org/) difference module", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "tape test/*.js", | ||
"doc": "dox -r < index.js | doxme --readme > README.md" | ||
"test": "tape test/*.js" | ||
}, | ||
@@ -27,10 +26,8 @@ "repository": { | ||
"glob": "~5.0.5", | ||
"tape": "~4.0.0", | ||
"dox": "^0.7.1", | ||
"doxme": "^1.8.2" | ||
"tape": "~4.0.0" | ||
}, | ||
"dependencies": { | ||
"jsts": "~0.15.0", | ||
"turf-featurecollection": "^1.0.1" | ||
"jsts": "1.1.1", | ||
"turf-helpers": "^3.0.0-canary.2f5f7167" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
NPM Shrinkwrap
Supply chain riskPackage contains a shrinkwrap file. This may allow the package to bypass normal install procedures.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
3
0
0
1
5573
5
106
1
1
+ Addedjsts@1.1.1(transitive)
+ Addedturf-helpers@3.0.12(transitive)
- Removedturf-featurecollection@^1.0.1
- Removedjavascript.util@0.12.12(transitive)
- Removedjsts@0.15.0(transitive)
- Removedturf-featurecollection@1.0.1(transitive)
Updatedjsts@1.1.1