[jira] [Comment Edited] (LUCENE-8712) Polygon2D does not detect crossings in some cases

2019-03-05 Thread Nicholas Knize (JIRA)


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

Nicholas Knize edited comment on LUCENE-8712 at 3/5/19 6:47 PM:


I took a quick look at this and agree the test case posted exposes a bug in 
{{EdgeTree.relateTriangle}}. The problem is in LUCENE-8679 we added a binary 
condition that returns {{CELL_OUTSIDE_QUERY}} unless {{insideEdges == 3}}. When 
Instead, in the case that {{insideEdges != 3}} but {{insideEdges > 0}} should 
return {{CELL_CROSSES}} query.

Another important thing to note, {{GeoUtils.lineRelateLine}} satisfies the 
commutative property. So line order does not matter: line 1 terminating at line 
2 == line 2 terminating at line 1 == {{CELL_INSIDE_QUERY}}  So 
{{testLineRelateLine}} will always fail because its assuming order will change 
the result.

I've posted a quick patch that corrects the bug posted. There's also some code 
refactoring that renames all instances of {{min/max}} {{lat/lon}} for the 
triangle to {{triMin/triMax }} {{lat/lon}} to avoid confusion w/ the bounding 
box of the polygon.


was (Author: nknize):
I took a quick look at this and agree the test case posted exposes a bug in 
{{EdgeTree.relateTriangle}}. The problem is in LUCENE-8679 we added a binary 
condition that returns {{CELL_OUTSIDE_QUERY}} unless {{insideEdges == 3}}. When 
Instead, in the case that {{insideEdges != 3}} but {{insideEdges > 0}} should 
return {{CELL_CROSSES}} query.

Another important thing to note, {{GeoUtils.lineRelateLine}} satisfies the 
commutative property. So line order does not matter: line 1 terminating at line 
2 == line 2 terminating at line 1 == {{CELL_INSIDE_QUERY}}

I've posted a quick patch that corrects the bug posted. There's also some code 
refactoring that renames all instances of {{min/max}} {{lat/lon}} for the 
triangle to {{triMin/triMax }} {{lat/lon}} to avoid confusion w/ the bounding 
box of the polygon.

> 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: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Comment Edited] (LUCENE-8712) Polygon2D does not detect crossings in some cases

2019-03-05 Thread Nicholas Knize (JIRA)


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

Nicholas Knize edited comment on LUCENE-8712 at 3/5/19 6:41 PM:


I took a quick look at this and agree the test case posted exposes a bug in 
{{EdgeTree.relateTriangle}}. The problem is in LUCENE-8679 we added a binary 
condition that returns {{CELL_OUTSIDE_QUERY}} unless {{insideEdges == 3}}. When 
Instead, in the case that {{insideEdges != 3}} but {{insideEdges > 0}} should 
return {{CELL_CROSSES}} query.

Another important thing to note, {{GeoUtils.lineRelateLine}} satisfies the 
commutative property. So line order does not matter: line 1 terminating at line 
2 == line 2 terminating at line 1 == {{CELL_INSIDE_QUERY}}

I've posted a quick patch that corrects the bug posted. There's also some code 
refactoring that renames all instances of {{min/max}} {{lat/lon}} for the 
triangle to {{triMin/triMax }} {{lat/lon}} to avoid confusion w/ the bounding 
box of the polygon.


was (Author: nknize):
I took a quick look at this and agree the test case posted exposes a bug in 
{{EdgeTree.relateTriangle}}. The problem is in LUCENE-8679 we added a binary 
condition that {{CELL_OUTSIDE_QUERY}} unless {{insideEdges == 3}}. Instead, 
{{insideEdges != 3}} but  {{insideEdges > 0}} should return {{CELL_CROSSES}} 
query. 

Another important thing to note, {{GeoUtils.lineRelateLine}} satisfies the 
commutative property. So line order does not matter: line 1 terminating at line 
2 == line 2 terminating at line 1 == {{CELL_INSIDE_QUERY}}

> 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: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Comment Edited] (LUCENE-8712) Polygon2D does not detect crossings in some cases

2019-03-04 Thread Ignacio Vera (JIRA)


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

Ignacio Vera edited comment on LUCENE-8712 at 3/5/19 7:55 AM:
--

-I have a go at this. I think the issue is in the method 
GeoUtils#lineRelateLine. Currently it return the {{Relation.CELL_INSIDE_QUERY}} 
if any of the segments terminates on the other.- 

-I think the logic should only return that if the first segment terminates on 
the other, otherwise should return {{Relation.CELL_CROSSES_QUERY.}}-

 

I have a closer look and it seems this approach still will misshandle  some 
situations.


was (Author: ivera):
I have a go to this. I think the issue is in the method 
GeoUtils#lineRelateLine. Currently it return the {{Relation.CELL_INSIDE_QUERY}} 
if any of the segments terminates on the other. 

I think the logic should only return that if the first segment terminates on 
the other, otherwise should return {{Relation.CELL_CROSSES_QUERY.}}

> 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
>
>
> 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: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org