Apache Solr open-source search software
LUCENE-8746: Call relate line with points in the same order as they come from the original tessellation.
iverase39fcd907fb38
diff --git a/lucene/core/src/java/org/apache/lucene/geo/Polygon2D.java b/lucene/core/src/java/org/apache/lucene/geo/Polygon2D.javaindex 3b06d219e1b..cf06ebd9269 100644--- a/lucene/core/src/java/org/apache/lucene/geo/Polygon2D.java+++ b/lucene/core/src/java/org/apache/lucene/geo/Polygon2D.java@@ -156,12 +156,15 @@ public class Polygon2D implements Component2D {if (ax == bx && bx == cx && ay == by && by == cy) {// indexed "triangle" is a point: shortcut by checking containsreturn internalContains(ax, ay) ? Relation.CELL_INSIDE_QUERY : Relation.CELL_OUTSIDE_QUERY;- } else if ((ax == cx && ay == cy) || (bx == cx && by == cy)) {+ } else if (ax == cx && ay == cy) {// indexed "triangle" is a line segment: shortcut by calling appropriate methodreturn relateIndexedLineSegment(minX, maxX, minY, maxY, ax, ay, bx, by);- } else if ((ax == bx && ay == by)) {+ } else if (ax == bx && ay == by) {// indexed "triangle" is a line segment: shortcut by calling appropriate method- return relateIndexedLineSegment(minX, maxX, minY, maxY, ax, ay, cx, cy);+ return relateIndexedLineSegment(minX, maxX, minY, maxY, bx, by, cx, cy);+ } else if (bx == cx && by == cy) {+ // indexed "triangle" is a line segment: shortcut by calling appropriate method+ return relateIndexedLineSegment(minX, maxX, minY, maxY, cx, cy, ax, ay);}// indexed "triangle" is a triangle:return relateIndexedTriangle(minX, maxX, minY, maxY, ax, ay, bx, by, cx, cy);diff --git a/lucene/sandbox/src/java/org/apache/lucene/geo/Line2D.java b/lucene/sandbox/src/java/org/apache/lucene/geo/Line2D.javaindex 15c923ee791..02d1422d9f4 100644--- a/lucene/sandbox/src/java/org/apache/lucene/geo/Line2D.java+++ b/lucene/sandbox/src/java/org/apache/lucene/geo/Line2D.java@@ -107,15 +107,21 @@ public final class Line2D implements Component2D {if (tree.isPointOnLine(ax, ay)) {return Relation.CELL_INSIDE_QUERY;}- } else if ((ax == cx && ay == cy) || (bx == cx && by == cy)) {+ } else if (ax == cx && ay == cy) {// indexed "triangle" is a line:if (tree.crossesLine(minX, maxX, minY, maxY, ax, ay, bx, by)) {return Relation.CELL_CROSSES_QUERY;}return Relation.CELL_OUTSIDE_QUERY;- } else if ((ax == bx && ay == by)) {+ } else if (ax == bx && ay == by) {// indexed "triangle" is a line:- if (tree.crossesLine(minX, maxX, minY, maxY, ax, ay, cx, cy)) {+ if (tree.crossesLine(minX, maxX, minY, maxY, bx, by, cx, cy)) {+ return Relation.CELL_CROSSES_QUERY;+ }+ return Relation.CELL_OUTSIDE_QUERY;+ } else if (bx == cx && by == cy) {+ // indexed "triangle" is a line:+ if (tree.crossesLine(minX, maxX, minY, maxY, cx, cy, ax, ay)) {return Relation.CELL_CROSSES_QUERY;}return Relation.CELL_OUTSIDE_QUERY;diff --git a/lucene/sandbox/src/test/org/apache/lucene/document/BaseShapeEncodingTestCase.java b/lucene/sandbox/src/test/org/apache/lucene/document/BaseShapeEncodingTestCase.javaindex e7642a975d8..ee71047f048 100644--- a/lucene/sandbox/src/test/org/apache/lucene/document/BaseShapeEncodingTestCase.java+++ b/lucene/sandbox/src/test/org/apache/lucene/document/BaseShapeEncodingTestCase.java@@ -472,7 +472,6 @@ public abstract class BaseShapeEncodingTestCase extends LuceneTestCase {verifyEncoding(ay, ax, ay, ax, ay, ax);}- @AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-8746")public void testRandomLineEncoding() {double ay = nextY();double ax = nextX();