diff --git a/lucene/core/src/java/org/apache/lucene/geo/Polygon2D.java b/lucene/core/src/java/org/apache/lucene/geo/Polygon2D.java index c0931b03df3..7db8287f61b 100644 --- a/lucene/core/src/java/org/apache/lucene/geo/Polygon2D.java +++ b/lucene/core/src/java/org/apache/lucene/geo/Polygon2D.java @@ -124,13 +124,9 @@ public final class Polygon2D extends EdgeTree { } } if (ax == bx && bx == cx && ay == by && by == cy) { - // indexed "triangle" is a point: - if (Rectangle.containsPoint(ay, ax, minLat, maxLat, minLon, maxLon) == false) { - return Relation.CELL_OUTSIDE_QUERY; - } - // shortcut by checking contains + // indexed "triangle" is a point: shortcut by checking contains return contains(ay, ax) ? Relation.CELL_INSIDE_QUERY : Relation.CELL_OUTSIDE_QUERY; - } else if (ax == cx && ay == cy) { + } else if ((ax == cx && ay == cy) || (bx == cx && by == cy)) { // indexed "triangle" is a line segment: shortcut by calling appropriate method return relateIndexedLineSegment(ax, ay, bx, by); } diff --git a/lucene/sandbox/src/java/org/apache/lucene/geo/Line2D.java b/lucene/sandbox/src/java/org/apache/lucene/geo/Line2D.java index 797892e40c5..9f413195b8f 100644 --- a/lucene/sandbox/src/java/org/apache/lucene/geo/Line2D.java +++ b/lucene/sandbox/src/java/org/apache/lucene/geo/Line2D.java @@ -57,7 +57,7 @@ public final class Line2D extends EdgeTree { if (isPointOnLine(tree, ax, ay)) { return Relation.CELL_INSIDE_QUERY; } - } else if (ax == cx && ay == cy) { + } else if ((ax == cx && ay == cy) || (bx == cx && by == cy)) { // indexed "triangle" is a line: if (tree.crossesLine(ax, ay, bx, by)) { return Relation.CELL_CROSSES_QUERY;