From b5dd71198d18a26752bcda16ad761b78a7616105 Mon Sep 17 00:00:00 2001 From: Karl David Wright Date: Thu, 24 Nov 2022 02:45:44 -0500 Subject: [PATCH] Refactor, restoring isWithinSection and making sure it is properly called. --- .../spatial3d/geom/GeoDegeneratePath.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) 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)); }