LUCENE-8061: Add convenience factory methods for building solids and BBoxes using bounds objects. Committed in part on behalf of Ignacio Vera.

This commit is contained in:
Karl Wright 2017-11-22 15:02:23 -05:00
parent e33e78c168
commit 558fc4b52b
2 changed files with 27 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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());
}
}