Github user dsmiley commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/246#discussion_r138329683 --- Diff: lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java --- @@ -14,70 +14,69 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.lucene.spatial.spatial4j; +import org.apache.lucene.spatial3d.geom.GeoArea; +import org.apache.lucene.spatial3d.geom.GeoAreaFactory; +import org.apache.lucene.spatial3d.geom.GeoAreaShape; +import org.apache.lucene.spatial3d.geom.GeoBBox; +import org.apache.lucene.spatial3d.geom.GeoBBoxFactory; +import org.apache.lucene.spatial3d.geom.GeoPoint; +import org.apache.lucene.spatial3d.geom.LatLonBounds; import org.locationtech.spatial4j.context.SpatialContext; import org.locationtech.spatial4j.distance.DistanceUtils; import org.locationtech.spatial4j.shape.Point; import org.locationtech.spatial4j.shape.Rectangle; import org.locationtech.spatial4j.shape.Shape; import org.locationtech.spatial4j.shape.SpatialRelation; -import org.locationtech.spatial4j.shape.impl.RectangleImpl; -import org.apache.lucene.spatial3d.geom.LatLonBounds; -import org.apache.lucene.spatial3d.geom.GeoArea; -import org.apache.lucene.spatial3d.geom.GeoAreaFactory; -import org.apache.lucene.spatial3d.geom.GeoPoint; -import org.apache.lucene.spatial3d.geom.GeoShape; -import org.apache.lucene.spatial3d.geom.PlanetModel; /** - * A Spatial4j Shape wrapping a {@link GeoShape} ("Geo3D") -- a 3D planar geometry based Spatial4j Shape implementation. + * A Spatial4j Shape wrapping a {@link GeoAreaShape} ("Geo3D") -- a 3D planar geometry + * based Spatial4j Shape implementation. * Geo3D implements shapes on the surface of a sphere or ellipsoid. * + * @param <T> is the type of {@link GeoAreaShape} + * * @lucene.experimental */ -public class Geo3dShape implements Shape { - /** The required size of this adjustment depends on the actual planetary model chosen. - * This value is big enough to account for WGS84. */ - protected static final double ROUNDOFF_ADJUSTMENT = 0.05; - public final SpatialContext ctx; - public final GeoShape shape; - public final PlanetModel planetModel; +public class Geo3dShape<T extends GeoAreaShape> implements Shape { - private volatile Rectangle boundingBox = null; // lazy initialized + protected final SpatialContext spatialcontext; - public Geo3dShape(final GeoShape shape, final SpatialContext ctx) { - this(PlanetModel.SPHERE, shape, ctx); - } + protected T shape; + protected volatile Rectangle boundingBox = null; // lazy initialized + protected volatile Point center = null; // lazy initialized - public Geo3dShape(final PlanetModel planetModel, final GeoShape shape, final SpatialContext ctx) { - if (!ctx.isGeo()) { - throw new IllegalArgumentException("SpatialContext.isGeo() must be true"); - } - this.ctx = ctx; - this.planetModel = planetModel; + public Geo3dShape(final T shape, final SpatialContext spatialcontext){ + this.spatialcontext = spatialcontext; this.shape = shape; } @Override - public SpatialContext getContext() { - return ctx; - } - - @Override public SpatialRelation relate(Shape other) { - if (other instanceof Rectangle) - return relate((Rectangle)other); - else if (other instanceof Point) - return relate((Point)other); - else - throw new RuntimeException("Unimplemented shape relationship determination: " + other.getClass()); + if (other instanceof Geo3dShape<?>){ + int relationship = shape.getRelationship(((Geo3dShape<?>)other).shape); --- End diff -- in the keeping of the style of other Shape classes, I suggest extracting a public overloaded method accepting Geo3dShape type
--- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org