Skip to content

Commit

Permalink
Add Feature<null> & drop extra JSON.stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere authored Aug 4, 2017
1 parent 9297684 commit fd592c0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/turf-intersect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ module.exports = function (poly1, poly2) {
var geom2 = (poly2.type === 'Feature') ? poly2.geometry : poly2;

var reader = new jsts.io.GeoJSONReader();
var a = reader.read(JSON.stringify(truncate(geom1)));
var b = reader.read(JSON.stringify(truncate(geom2)));
var a = reader.read(truncate(geom1));
var b = reader.read(truncate(geom2));
var intersection = a.intersection(b);

if (intersection.isEmpty()) return null;
if (intersection.isEmpty()) return {
type: 'Feature',
properties: {},
geometry: null
};

var writer = new jsts.io.GeoJSONWriter();
var geojsonGeometry = writer.write(intersection);
Expand Down

0 comments on commit fd592c0

Please sign in to comment.