Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-9870

Circle2D intersectsLine bug mostly causes no matches along indexed lines and outside polygon edges

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 8.8
    • 8.8.2
    • modules/spatial
    • New

    Description

      Circle2D intersectsLine does a dot product to determine closest point on line but then filters it like this:
       

      
          final double distance = dotProduct / magnitudeAB;
      
          if (distance < 0 || distance > dotProduct) {
            return false;
          }
      
      

      If magnitudeAB (squared length of line) is less than 1 (degree), this will always return false.

      distance is actually the "t-value", meaning the correct behaviour here would be to clamp it between 0 and 1 to ensure point is on actual line.

      A straightforward fix that works since edge and end points are checked anyway:

      
          final double distance = dotProduct / magnitudeAB;
      
          if (distance < 0 || distance > 1) {
            return false;
          }
      
      

      This is tested and verified by building version 8.8.0 and replacing jar-files in an elasticsearch instance of version 7.12.

      Attachments

        Issue Links

          Activity

            People

              ivera Ignacio Vera
              jnystad Jørgen Nystad
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 40m
                  1h 40m