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/22 23:43:50 UTC
[lucene] branch revamp_geopath updated: Make sure use of aggregation form is consistent throughout, and fix segment endpoint computations of nearestDistance.
This is an automated email from the ASF dual-hosted git repository.
kwright pushed a commit to branch revamp_geopath
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/revamp_geopath by this push:
new c9c27c755a4 Make sure use of aggregation form is consistent throughout, and fix segment endpoint computations of nearestDistance.
c9c27c755a4 is described below
commit c9c27c755a469256f64845dc7653b31b32ea6916
Author: Karl David Wright <kw...@apache.org>
AuthorDate: Tue Nov 22 18:43:19 2022 -0500
Make sure use of aggregation form is consistent throughout, and fix segment endpoint computations of nearestDistance.
---
.../lucene/spatial3d/geom/DistanceStyle.java | 11 ++++---
.../lucene/spatial3d/geom/GeoStandardPath.java | 34 +++++++++++++---------
2 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/DistanceStyle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/DistanceStyle.java
index b90ff18e46d..f5d9cb61b22 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/DistanceStyle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/DistanceStyle.java
@@ -114,12 +114,15 @@ public interface DistanceStyle {
* converted to aggregation form before aggregation is attempted, and they should be converted
* back from aggregation form to yield a final result.
*
- * @param distance1 is the first aggregation form distance.
- * @param distance2 is the second aggregation form distance.
+ * @param distances are the distances to aggregate.
* @return the combined aggregation form distance.
*/
- public default double aggregateDistances(final double distance1, final double distance2) {
- return distance1 + distance2;
+ public default double aggregateDistances(final double... distances) {
+ double rval = 0.0;
+ for (final double distance : distances) {
+ rval += distance;
+ }
+ return rval;
}
/**
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
index f08413aaa87..ab3eb4f80f3 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
@@ -277,7 +277,8 @@ class GeoStandardPath extends GeoBasePath {
if (rootComponent == null) {
return Double.POSITIVE_INFINITY;
}
- return rootComponent.pathCenterDistance(distanceStyle, x, y, z);
+ return distanceStyle.fromAggregationForm(
+ rootComponent.pathCenterDistance(distanceStyle, x, y, z));
}
@Override
@@ -286,7 +287,7 @@ class GeoStandardPath extends GeoBasePath {
if (rootComponent == null) {
return Double.POSITIVE_INFINITY;
}
- return rootComponent.nearestDistance(distanceStyle, x, y, z);
+ return distanceStyle.fromAggregationForm(rootComponent.nearestDistance(distanceStyle, x, y, z));
}
@Override
@@ -295,7 +296,7 @@ class GeoStandardPath extends GeoBasePath {
if (rootComponent == null) {
return Double.POSITIVE_INFINITY;
}
- return rootComponent.distance(distanceStyle, x, y, z);
+ return distanceStyle.fromAggregationForm(rootComponent.distance(distanceStyle, x, y, z));
}
@Override
@@ -321,7 +322,7 @@ class GeoStandardPath extends GeoBasePath {
if (rootComponent == null) {
return Double.POSITIVE_INFINITY;
}
- return rootComponent.outsideDistance(distanceStyle, x, y, z);
+ return distanceStyle.fromAggregationForm(rootComponent.outsideDistance(distanceStyle, x, y, z));
}
@Override
@@ -814,8 +815,7 @@ class GeoStandardPath extends GeoBasePath {
}
final double startingDistance = getStartingDistance(distanceStyle);
final double pathDistance = pathDistance(distanceStyle, x, y, z);
- return distanceStyle.fromAggregationForm(
- distanceStyle.aggregateDistances(startingDistance, pathDistance));
+ return distanceStyle.aggregateDistances(startingDistance, pathDistance);
}
@Override
@@ -824,7 +824,10 @@ class GeoStandardPath extends GeoBasePath {
if (!isWithinSection(x, y, z)) {
return Double.POSITIVE_INFINITY;
}
- return distanceStyle.fromAggregationForm(getStartingDistance(distanceStyle));
+ return distanceStyle.aggregateDistances(
+ getStartingDistance(distanceStyle),
+ nearestPathDistance(distanceStyle, x, y, z),
+ pathCenterDistance(distanceStyle, x, y, z));
}
@Override
@@ -867,13 +870,13 @@ class GeoStandardPath extends GeoBasePath {
if (!isWithinSection(x, y, z)) {
return Double.POSITIVE_INFINITY;
}
- return distanceStyle.computeDistance(this.point, x, y, z);
+ return distanceStyle.toAggregationForm(distanceStyle.computeDistance(this.point, x, y, z));
}
@Override
public double outsideDistance(
final DistanceStyle distanceStyle, final double x, final double y, final double z) {
- return distanceStyle.computeDistance(this.point, x, y, z);
+ return distanceStyle.toAggregationForm(distanceStyle.computeDistance(this.point, x, y, z));
}
@Override
@@ -1461,8 +1464,8 @@ class GeoStandardPath extends GeoBasePath {
}
return distanceStyle.fromAggregationForm(
distanceStyle.aggregateDistances(
- distanceStyle.aggregateDistances(
- getStartingDistance(distanceStyle), nearestPathDistance(distanceStyle, x, y, z)),
+ getStartingDistance(distanceStyle),
+ nearestPathDistance(distanceStyle, x, y, z),
pathCenterDistance(distanceStyle, x, y, z)));
}
@@ -1734,9 +1737,12 @@ class GeoStandardPath extends GeoBasePath {
final double URHCDistance = distanceStyle.computeDistance(URHC, x, y, z);
final double LLHCDistance = distanceStyle.computeDistance(LLHC, x, y, z);
final double LRHCDistance = distanceStyle.computeDistance(LRHC, x, y, z);
- return Math.min(
- Math.min(Math.min(upperDistance, lowerDistance), Math.min(startDistance, endDistance)),
- Math.min(Math.min(ULHCDistance, URHCDistance), Math.min(LLHCDistance, LRHCDistance)));
+ return distanceStyle.toAggregationForm(
+ Math.min(
+ Math.min(
+ Math.min(upperDistance, lowerDistance), Math.min(startDistance, endDistance)),
+ Math.min(
+ Math.min(ULHCDistance, URHCDistance), Math.min(LLHCDistance, LRHCDistance))));
}
@Override