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

Ignacio Vera commented on LUCENE-8712:
--------------------------------------

There is something that is not right in this approach as the result depends on 
the order the edges of tree are processed. This will fail in some situations, 
for example the following random test will eventually fail:

{code:java}
public void testRandomLineCrossingPolygon() {
  Polygon p = GeoTestUtil.createRegularPolygon(0, 0, 1000, 
TestUtil.nextInt(random(), 100, 10000));
  Polygon2D polygon2D = Polygon2D.create(p);
  for (int i=0; i < 1000; i ++) {
    double longitude = GeoTestUtil.nextLongitude();
    double latitude = GeoTestUtil.nextLatitude();
    PointValues.Relation rel = polygon2D.relateTriangle(
        
GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(-longitude)),
        
GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(-latitude)),
        
GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(longitude)),
        
GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(latitude)),
        
GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(-longitude)),
        
GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(-latitude)));
    assertNotEquals(PointValues.Relation.CELL_OUTSIDE_QUERY, rel);
  }
}{code}

I think in this case we should return {{CELL_CROSSES}} if {{inside_edges}} > 0 
instead of setting the value to {{rel}}. But in this case LUCENE8669 will fail. 

> Polygon2D does not detect crossings in some cases
> -------------------------------------------------
>
>                 Key: LUCENE-8712
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8712
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Ignacio Vera
>            Priority: Major
>         Attachments: LUCENE-8712.patch, LUCENE-8712.patch
>
>
> Polygon2D does not detect crossing if the triangle crosses through points of 
> the polygon and none of the points are inside it. For example:
>  
> {code:java}
> public void testLineCrossingPolygonPoints() {
>   Polygon p = new Polygon(new double[] {0, -1, 0, 1, 0}, new double[] {-1, 0, 
> 1, 0, -1});
>   Polygon2D polygon2D = Polygon2D.create(p);
>   PointValues.Relation rel = 
> polygon2D.relateTriangle(GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(-1.5)),
>       GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(0)),
>       GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(1.5)),
>       GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(0)),
>       
> GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(-1.5)),
>       GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(0)));
>   assertEquals(PointValues.Relation.CELL_CROSSES_QUERY, rel);
> }{code}
> [~nknize] you might want to look at this as I am not sure what to do.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to