You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by iv...@apache.org on 2018/11/07 06:46:55 UTC

lucene-solr:branch_7x: LUCENE-8559: Fix bug where polygon edges were skipped when checking for intersections

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 12719d196 -> d214f968d


LUCENE-8559: Fix bug where polygon edges were skipped when checking for intersections


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d214f968
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d214f968
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d214f968

Branch: refs/heads/branch_7x
Commit: d214f968d765e5c30c8782c5545c38d9aef487fe
Parents: 12719d1
Author: iverase <iv...@apache.org>
Authored: Wed Nov 7 07:46:25 2018 +0100
Committer: iverase <iv...@apache.org>
Committed: Wed Nov 7 07:46:25 2018 +0100

----------------------------------------------------------------------
 lucene/CHANGES.txt                                       |  3 +++
 .../src/java/org/apache/lucene/geo/Tessellator.java      | 11 +++++++----
 .../src/test/org/apache/lucene/geo/TestTessellator.java  |  7 +++++++
 3 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d214f968/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 94c3437..6e224da 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -40,6 +40,9 @@ Bug fixes:
 * LUCENE-8534: Fix incorrect computation for triangles intersecting polygon edges in
   shape tessellation. (Ignacio Vera)
 
+* LUCENE-8559: Fix bug where polygon edges were skipped when checking for intersections.
+  (Ignacio Vera)   
+
 New Features
 
 * LUCENE-8496: Selective indexing - modify BKDReader/BKDWriter to allow users

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d214f968/lucene/sandbox/src/java/org/apache/lucene/geo/Tessellator.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/geo/Tessellator.java b/lucene/sandbox/src/java/org/apache/lucene/geo/Tessellator.java
index 345a73b..8fa685c 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/geo/Tessellator.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/geo/Tessellator.java
@@ -540,9 +540,7 @@ final public class Tessellator {
     Node nextNode;
     do {
       nextNode = node.next;
-      if(node.getX() != x0 && node.getY() != y0 && nextNode.getX() != x0
-          && nextNode.getY() != y0 && node.getX() != x1 && node.getY() != y1
-          && nextNode.getX() != x1 && nextNode.getY() != y1) {
+      if(isVertexEquals(node, x0, y0) == false && isVertexEquals(node, x1, y1) == false) {
         if (linesIntersect(node.getX(), node.getY(), nextNode.getX(), nextNode.getY(), x0, y0, x1, y1)) {
           return true;
         }
@@ -709,7 +707,12 @@ final public class Tessellator {
 
   /** Determines if two point vertices are equal. **/
   private static final boolean isVertexEquals(final Node a, final Node b) {
-    return a.getX() == b.getX() && a.getY() == b.getY();
+    return isVertexEquals(a, b.getX(), b.getY());
+  }
+
+  /** Determines if two point vertices are equal. **/
+  private static final boolean isVertexEquals(final Node a, final double x, final  double y) {
+    return a.getX() == x && a.getY() == y;
   }
 
   /** Compute signed area of triangle */

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d214f968/lucene/sandbox/src/test/org/apache/lucene/geo/TestTessellator.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/test/org/apache/lucene/geo/TestTessellator.java b/lucene/sandbox/src/test/org/apache/lucene/geo/TestTessellator.java
index 82ba5b4..7904725 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/geo/TestTessellator.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/geo/TestTessellator.java
@@ -96,4 +96,11 @@ public class TestTessellator extends LuceneTestCase {
     Polygon polygon = (Polygon)SimpleWKTShapeParser.parse(wkt);
     assertTrue(Tessellator.tessellate(polygon).size() == 8);
   }
+
+  public void testLUCENE8559()  throws Exception {
+    String wkt = "POLYGON((-0.1348674 51.7458255,-0.1345884 51.7455067,-0.1329898 51.745314,-0.1326358 51.745314,-0.1324105 51.744404,-0.131981 51.7444423,-0.1312196 51.7445102,-0.1310908 51.7456794,-0.1319706 51.7460713,-0.1343095 51.7465828,-0.1348674 51.7458255)," +
+        "(-0.1322388 51.7447959,-0.1322388 51.7454336,-0.1318633 51.7457126,-0.1313912 51.7456262,-0.1318985 51.7448032,-0.1322388 51.7447959))";
+    Polygon polygon = (Polygon)SimpleWKTShapeParser.parse(wkt);
+    assertTrue(Tessellator.tessellate(polygon).size() > 0);
+  }
 }
\ No newline at end of file