LUCENE-8746: Call relate line with points in the same order as they

come from the original tessellation.
This commit is contained in:
iverase 2019-10-16 07:20:45 +02:00
parent 939b3364e6
commit 39fcd907fb
3 changed files with 15 additions and 7 deletions

View File

@ -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 contains
return 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 method
return 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);

View File

@ -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;

View File

@ -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();