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

turf-intersect

Package Overview
Dependencies
Maintainers
9
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-intersect - npm Package Compare versions

Comparing version 1.4.2 to 3.0.0-canary.2f5f7167

.npmignore

41

index.js

@@ -7,3 +7,3 @@ // depend on jsts for now https://github.com/bjornharrtell/jsts/blob/master/examples/overlay.html

*
* @module turf/intersect
* @name intersect
* @category transformation

@@ -61,24 +61,25 @@ * @param {Feature<Polygon>} poly1 the first polygon

*/
module.exports = function(poly1, poly2){
var geom1, geom2;
if(poly1.type === 'Feature') geom1 = poly1.geometry;
else geom1 = poly1;
if(poly2.type === 'Feature') geom2 = poly2.geometry;
else geom2 = poly2;
var reader = new jsts.io.GeoJSONReader();
var a = reader.read(JSON.stringify(geom1));
var b = reader.read(JSON.stringify(geom2));
var intersection = a.intersection(b);
var parser = new jsts.io.GeoJSONParser();
module.exports = function intersect(poly1, poly2) {
var geom1, geom2;
if (poly1.type === 'Feature') geom1 = poly1.geometry;
else geom1 = poly1;
if (poly2.type === 'Feature') geom2 = poly2.geometry;
else geom2 = poly2;
var reader = new jsts.io.GeoJSONReader();
var a = reader.read(JSON.stringify(geom1));
var b = reader.read(JSON.stringify(geom2));
var intersection = a.intersection(b);
intersection = parser.write(intersection);
if(intersection.type === 'GeometryCollection' && intersection.geometries.length === 0) {
return;
} else {
if (intersection.isEmpty()) {
return undefined;
}
var writer = new jsts.io.GeoJSONWriter();
var geojsonGeometry = writer.write(intersection);
return {
type: 'Feature',
properties: {},
geometry: intersection
type: 'Feature',
properties: {},
geometry: geojsonGeometry
};
}
};
{
"name": "turf-intersect",
"version": "1.4.2",
"version": "3.0.0-canary.2f5f7167",
"description": "find the intersection of spatial features",
"main": "index.js",
"scripts": {
"test": "node test/test.js",
"doc": "dox -r < index.js | doxme --readme > README.md"
"test": "node test/test.js"
},

@@ -28,9 +27,7 @@ "repository": {

"glob": "~4.3.5",
"tape": "~3.5.0",
"dox": "^0.6.1",
"doxme": "^1.4.3"
"tape": "~3.5.0"
},
"dependencies": {
"jsts": "~0.15.0"
"jsts": "1.1.1"
}
}
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