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:11:41 UTC
[lucene] 01/02: Prevent NPEs while still handling the polar case for horizontal planes right off the pole
This is an automated email from the ASF dual-hosted git repository.
kwright pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git
commit 7f0e9daa9e5a0573eeb7fe0781f69ee54d998855
Author: Karl David Wright <kw...@apache.org>
AuthorDate: Wed Nov 16 11:03:24 2022 -0500
Prevent NPEs while still handling the polar case for horizontal planes right off the pole
---
.../java/org/apache/lucene/spatial3d/geom/Plane.java | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
index 5b09ee6e7d1..f9de81781b1 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
@@ -1662,9 +1662,14 @@ public class Plane extends Vector {
} else {
// Since a==b==0, any plane including the Z axis suffices.
// System.err.println(" Perpendicular to z");
- final GeoPoint[] points =
+ GeoPoint[] points =
findIntersections(planetModel, normalYPlane, NO_BOUNDS, NO_BOUNDS);
- if (points.length > 0) {
+ if (points.length == 0) {
+ points = findIntersections(planetModel, normalXPlane, NO_BOUNDS, NO_BOUNDS);
+ }
+ if (points.length == 0) {
+ boundsInfo.addZValue(new GeoPoint(0.0, 0.0, -this.z));
+ } else {
boundsInfo.addZValue(points[0]);
}
}
@@ -2204,9 +2209,16 @@ public class Plane extends Vector {
}
} else {
// Horizontal circle. Since a==b, any vertical plane suffices.
- final GeoPoint[] points =
+ GeoPoint[] points =
findIntersections(planetModel, normalXPlane, NO_BOUNDS, NO_BOUNDS);
- boundsInfo.addZValue(points[0]);
+ if (points.length == 0) {
+ points = findIntersections(planetModel, normalYPlane, NO_BOUNDS, NO_BOUNDS);
+ }
+ if (points.length == 0) {
+ boundsInfo.addZValue(new GeoPoint(0.0, 0.0, -this.z));
+ } else {
+ boundsInfo.addZValue(points[0]);
+ }
}
// System.err.println("Done latitude bounds");
}