Turfjs / turf

A modular geospatial engine written in JavaScript and TypeScript

Home Page:https://turfjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

booleanIntersects obvious performance improvement

stevage opened this issue · 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.