[ 
https://issues.apache.org/jira/browse/LUCENE-9870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17308745#comment-17308745
 ] 

Jørgen Nystad commented on LUCENE-9870:
---------------------------------------

PR opened.

> Circle2D intersectsLine bug mostly causes no matches along indexed lines and 
> outside polygon edges
> --------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-9870
>                 URL: https://issues.apache.org/jira/browse/LUCENE-9870
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: modules/spatial
>    Affects Versions: 8.8
>            Reporter: Jørgen Nystad
>            Priority: Major
>              Labels: easyfix
>         Attachments: 
> 0001-Circle2D-Fix-intersectsLine-t-value-distance-range-c.patch
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Circle2D intersectsLine does a dot product to determine closest point on line 
> but then filters it like this:
>  
> {code:java}
>     final double distance = dotProduct / magnitudeAB;
>     if (distance < 0 || distance > dotProduct) {
>       return false;
>     }
> {code}
> 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:
> {code:java}
>     final double distance = dotProduct / magnitudeAB;
>     if (distance < 0 || distance > 1) {
>       return false;
>     }
> {code}
> This is tested and verified by building version 8.8.0 and replacing jar-files 
> in an elasticsearch instance of version 7.12.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to