turf-intersect
Advanced tools
Comparing version 1.4.2 to 3.0.0-canary.2f5f7167
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" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
3
0
0
1
5788
5
98
1
1
+ Addedjsts@1.1.1(transitive)
- Removedjavascript.util@0.12.12(transitive)
- Removedjsts@0.15.0(transitive)
Updatedjsts@1.1.1