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

turf-difference

Package Overview
Dependencies
Maintainers
2
Versions
8
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 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

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