Skip to content

Apache Lucene open-source search software

Refactor, restoring isWithinSection and making sure it is properly called.

Karl David Wrightb5dd71198d18
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java
index bba5a016c16..eb3086f7f16 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java
@@ -461,13 +461,30 @@ class GeoDegeneratePath extends GeoBasePath {
* @param x is the point x.
* @param y is the point y.
* @param z is the point z.
- * @return true of within.
+ * @return true if within.
*/
@Override
public boolean isWithin(final double x, final double y, final double z) {
return this.point.isIdentical(x, y, z);
}
+ /**
+ * Check if point is within the section handled by this endpoint.
+ *
+ * @param x is the point x.
+ * @param y is the point y.
+ * @param z is the point z.
+ * @return true if within.
+ */
+ public boolean isWithinSection(final double x, final double y, final double z) {
+ for (final Membership m : cutoffPlanes) {
+ if (!m.isWithin(x, y, z)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
/**
* Compute interior path distance.
*
@@ -497,10 +514,8 @@ class GeoDegeneratePath extends GeoBasePath {
*/
public double pathCenterDistance(
final DistanceStyle distanceStyle, final double x, final double y, final double z) {
- for (final Membership m : cutoffPlanes) {
- if (!m.isWithin(x, y, z)) {
- return Double.POSITIVE_INFINITY;
- }
+ if (!isWithinSection(x, y, z)) {
+ return Double.POSITIVE_INFINITY;
}
return distanceStyle.toAggregationForm(distanceStyle.computeDistance(this.point, x, y, z));
}