Github user dsmiley commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/246#discussion_r138329027
--- Diff:
lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dRectangleShape.java
---
@@ -30,32 +30,49 @@
import org.locationtech.spatial4j.shape.SpatialRelation;
/**
- * Specialization of a {@link Geo3dAreaShape} which represents a {@link
Rectangle}. This
+ * Specialization of a {@link Geo3dShape} which represents a {@link
Rectangle}. This
* class is used for geohashing.
*
* @lucene.experimental
*/
-public class Geo3dRectangleShape extends Geo3dAreaShape<GeoBBox>
implements Rectangle {
-
- //bounds object to return the max and min latitude and longitude
- private volatile LatLonBounds bounds; // lazy initialized
+public class Geo3dRectangleShape extends Geo3dShape<GeoBBox> implements
Rectangle {
+
+ private double minX;
+ private double maxX;
+ private double minY;
+ private double maxY;
+
+ public Geo3dRectangleShape(final GeoBBox shape,
+ final SpatialContext spatialcontext,
+ double minX,
+ double maxX,
+ double minY,
+ double maxY) {
+ super(shape, spatialcontext);
+ this.minX = minX;
+ this.maxX = maxX;
+ this.minY = minY;
+ this.maxY = maxY;
+ }
public Geo3dRectangleShape(final GeoBBox shape, final SpatialContext
spatialcontext) {
super(shape, spatialcontext);
+ setBounds();
}
+
+
/**
- * Get the bounds from the wrapped GeoBBox.
+ * Set the bounds from the wrapped GeoBBox.
* @return The bounds
*/
- private LatLonBounds getBounds() {
- LatLonBounds bounds = this.bounds;//volatile read once
- if (bounds == null) {
- bounds = new LatLonBounds();
- shape.getBounds(bounds);
- this.bounds = bounds;
- }
- return bounds;
+ private void setBounds() {
--- End diff --
minor: if this method accepted the shape field as a parameter, it would be
more clear from where the boundaries are coming from. Or give it a longer name
perhaps like setBoundsFromShape.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]