turf icon indicating copy to clipboard operation
turf copied to clipboard

booleanIntersects obvious performance improvement

Open stevage opened this issue 2 years ago • 0 comments

This bit of code could obviously be made faster with a non-exhaustive search

case "MultiPolygon":
      segmentEach(feature1, (segment1) => {
        segmentEach(feature2, (segment2) => {
          if (lineIntersect(segment1!, segment2!).features.length) overlap++;
        });
      });

This should be:

case "MultiPolygon":
      segmentEach(feature1, (segment1) => {
        segmentEach(feature2, (segment2) => {
          if (lineIntersect(segment1!, segment2!).features.length) return true;
        });
      });

Same in the case of LineString.

stevage avatar Jul 13 '23 07:07 stevage