You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kw...@apache.org on 2022/11/24 15:44:18 UTC

[lucene] branch main updated: Refactor, restoring isWithinSection and making sure it is properly called.

This is an automated email from the ASF dual-hosted git repository.

kwright pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new b5dd71198d1 Refactor, restoring isWithinSection and making sure it is properly called.
b5dd71198d1 is described below

commit b5dd71198d18a26752bcda16ad761b78a7616105
Author: Karl David Wright <kw...@apache.org>
AuthorDate: Thu Nov 24 02:45:44 2022 -0500

    Refactor, restoring isWithinSection and making sure it is properly called.
---
 .../lucene/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));
     }