Prevent NPEs while still handling the polar case for horizontal planes right off the pole

This commit is contained in:
Karl David Wright 2022-11-16 11:03:24 -05:00
parent 3c5bcb383b
commit b6ebfd1861
1 changed files with 16 additions and 4 deletions

View File

@ -1500,9 +1500,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]);
}
}
@ -2042,9 +2047,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");
}