@turf/intersect
Advanced tools
Comparing version 4.6.0 to 4.7.0
22
index.js
// depend on jsts for now http://bjornharrtell.github.io/jsts/ | ||
var jsts = require('jsts'); | ||
var truncate = require('@turf/truncate'); | ||
@@ -37,18 +38,17 @@ /** | ||
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 geom1 = (poly1.type === 'Feature') ? poly1.geometry : poly1; | ||
var geom2 = (poly2.type === 'Feature') ? poly2.geometry : poly2; | ||
var reader = new jsts.io.GeoJSONReader(); | ||
var a = reader.read(JSON.stringify(geom1)); | ||
var b = reader.read(JSON.stringify(geom2)); | ||
var a = reader.read(truncate(geom1)); | ||
var b = reader.read(truncate(geom2)); | ||
var intersection = a.intersection(b); | ||
if (intersection.isEmpty()) { | ||
return undefined; | ||
} | ||
if (intersection.isEmpty()) return { | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: null | ||
}; | ||
var writer = new jsts.io.GeoJSONWriter(); | ||
var geojsonGeometry = writer.write(intersection); | ||
@@ -55,0 +55,0 @@ return { |
{ | ||
"name": "@turf/intersect", | ||
"version": "4.6.0", | ||
"version": "4.7.0", | ||
"description": "turf intersect module", | ||
@@ -37,4 +37,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"@turf/truncate": "4.7.0", | ||
"jsts": "1.3.0" | ||
} | ||
} |
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
6760
2
+ Added@turf/truncate@4.7.0