Apache Lucene open-source search software
LUCENE-8061: Add convenience factory methods for building solids and BBoxes using bounds objects. Committed in part on behalf of Ignacio Vera.
Karl Wright558fc4b52b3b
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.javaindex 12d479bee24..28b3a799753 100755--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java@@ -116,4 +116,19 @@ public class GeoBBoxFactory {return new GeoRectangle(planetModel, topLat, bottomLat, leftLon, rightLon);}+ /**+ * Create a geobbox of the right kind given the specified {@link LatLonBounds}.+ *+ * @param planetModel is the planet model+ * @param bounds are the bounds+ * @return a GeoBBox corresponding to what was specified.+ */+ public static GeoBBox makeGeoBBox(final PlanetModel planetModel, LatLonBounds bounds) {+ final double topLat = (bounds.checkNoTopLatitudeBound()) ? Math.PI * 0.5 : bounds.getMaxLatitude();+ final double bottomLat = (bounds.checkNoBottomLatitudeBound()) ? -Math.PI * 0.5 : bounds.getMinLatitude();+ final double leftLon = (bounds.checkNoLongitudeBound()) ? -Math.PI : bounds.getLeftLongitude();+ final double rightLon = (bounds.checkNoLongitudeBound()) ? Math.PI : bounds.getRightLongitude();+ return makeGeoBBox(planetModel, topLat, bottomLat, leftLon, rightLon);+ }+}diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZSolidFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZSolidFactory.javaindex 25ea4005044..14b9bb62a8a 100644--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZSolidFactory.java+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZSolidFactory.java@@ -64,4 +64,16 @@ public class XYZSolidFactory {return new StandardXYZSolid(planetModel, minX, maxX, minY, maxY, minZ, maxZ);}+ /**+ * Create a XYZSolid of the right kind given (x,y,z) bounds.+ * @param planetModel is the planet model+ * @param bounds is the XYZ bounds object.+ * @return the solid.+ */+ public static XYZSolid makeXYZSolid(final PlanetModel planetModel, final XYZBounds bounds) {+ return makeXYZSolid(planetModel, bounds.getMinimumX(), bounds.getMaximumX(),+ bounds.getMinimumY(), bounds.getMaximumY(),+ bounds.getMinimumZ(), bounds.getMaximumZ());+ }+}