You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kw...@apache.org on 2017/08/03 13:50:12 UTC
[3/3] lucene-solr:branch_6x: LUCENE-7606: Add spatial relationships
between all currently-defined Geo shapes
LUCENE-7606: Add spatial relationships between all currently-defined Geo shapes
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/b294052d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/b294052d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/b294052d
Branch: refs/heads/branch_6x
Commit: b294052d581719ebb3bf538aace07d5f5deb303b
Parents: 5aa7142
Author: Karl Wright <Da...@gmail.com>
Authored: Thu Aug 3 09:32:11 2017 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Thu Aug 3 09:48:03 2017 -0400
----------------------------------------------------------------------
.../lucene/spatial3d/geom/GeoAreaShape.java | 39 +
.../apache/lucene/spatial3d/geom/GeoBBox.java | 2 +-
.../lucene/spatial3d/geom/GeoBaseAreaShape.java | 125 +++
.../lucene/spatial3d/geom/GeoBaseBBox.java | 38 +-
.../spatial3d/geom/GeoBaseDistanceShape.java | 2 +-
.../lucene/spatial3d/geom/GeoBasePolygon.java | 2 +-
.../spatial3d/geom/GeoComplexPolygon.java | 45 +-
.../spatial3d/geom/GeoCompositeAreaShape.java | 141 +++
.../geom/GeoCompositeMembershipShape.java | 7 +-
.../spatial3d/geom/GeoCompositePolygon.java | 2 +-
.../spatial3d/geom/GeoConcavePolygon.java | 21 +
.../lucene/spatial3d/geom/GeoConvexPolygon.java | 21 +
.../geom/GeoDegenerateHorizontalLine.java | 7 +-
.../geom/GeoDegenerateLatitudeZone.java | 7 +-
.../geom/GeoDegenerateLongitudeSlice.java | 7 +-
.../spatial3d/geom/GeoDegeneratePoint.java | 5 +
.../geom/GeoDegenerateVerticalLine.java | 7 +-
.../lucene/spatial3d/geom/GeoDistanceShape.java | 2 +-
.../lucene/spatial3d/geom/GeoLatitudeZone.java | 46 +-
.../spatial3d/geom/GeoLongitudeSlice.java | 33 +-
.../spatial3d/geom/GeoNorthLatitudeZone.java | 38 +-
.../spatial3d/geom/GeoNorthRectangle.java | 45 +-
.../lucene/spatial3d/geom/GeoPolygon.java | 2 +-
.../lucene/spatial3d/geom/GeoRectangle.java | 45 +-
.../spatial3d/geom/GeoSouthLatitudeZone.java | 37 +-
.../spatial3d/geom/GeoSouthRectangle.java | 43 +-
.../spatial3d/geom/GeoStandardCircle.java | 8 +
.../lucene/spatial3d/geom/GeoStandardPath.java | 37 +
.../geom/GeoWideDegenerateHorizontalLine.java | 9 +-
.../spatial3d/geom/GeoWideLongitudeSlice.java | 32 +-
.../spatial3d/geom/GeoWideNorthRectangle.java | 48 +-
.../lucene/spatial3d/geom/GeoWideRectangle.java | 46 +-
.../spatial3d/geom/GeoWideSouthRectangle.java | 44 +-
.../apache/lucene/spatial3d/geom/GeoWorld.java | 5 +
.../CompositeGeoPolygonRelationshipsTest.java | 842 +++++++++++++++++
.../spatial3d/geom/RandomGeoShapeGenerator.java | 944 +++++++++++++++++++
.../geom/RandomGeoShapeRelationshipTest.java | 240 +++++
.../geom/SimpleGeoPolygonRelationshipsTest.java | 837 ++++++++++++++++
38 files changed, 3433 insertions(+), 428 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoAreaShape.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoAreaShape.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoAreaShape.java
new file mode 100644
index 0000000..b00ffca
--- /dev/null
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoAreaShape.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.spatial3d.geom;
+
+/**
+ * Shape that implements GeoArea. This type of shapes are able to resolve the
+ * spatial relationship of other shapes with itself.
+ *
+ * @lucene.experimental
+ */
+
+public interface GeoAreaShape extends GeoMembershipShape, GeoArea{
+
+ /**
+ * Assess whether a shape intersects with any of the edges this shape.
+ * Note well that this method return false if the shape contains, is within
+ * or is disjoint with the given shape.
+ *
+ * @param geoShape is the shape to assess for intersection with this shape's edges.
+ *
+ * @return true if there's such an intersection, false if not.
+ */
+ boolean intersects(GeoShape geoShape);
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBox.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBox.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBox.java
index 0ae2425..683333c 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBox.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBox.java
@@ -23,7 +23,7 @@ package org.apache.lucene.spatial3d.geom;
*
* @lucene.experimental
*/
-public interface GeoBBox extends GeoMembershipShape, GeoSizeable, GeoArea {
+public interface GeoBBox extends GeoAreaShape, GeoSizeable {
/**
* Expand box by specified angle.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseAreaShape.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseAreaShape.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseAreaShape.java
new file mode 100644
index 0000000..5bd8ab3
--- /dev/null
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseAreaShape.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.spatial3d.geom;
+
+/**
+ * Base extended areaShape object.
+ *
+ * @lucene.internal
+ */
+abstract class GeoBaseAreaShape extends GeoBaseMembershipShape implements GeoAreaShape {
+
+ /** Constructor.
+ *@param planetModel is the planet model to use.
+ */
+ public GeoBaseAreaShape(final PlanetModel planetModel) {
+ super(planetModel);
+ }
+
+ /** All edgepoints inside shape */
+ protected final static int ALL_INSIDE = 0;
+ /** Some edgepoints inside shape */
+ protected final static int SOME_INSIDE = 1;
+ /** No edgepoints inside shape */
+ protected final static int NONE_INSIDE = 2;
+
+ /** Determine the relationship between the GeoAreShape and the
+ * shape's edgepoints.
+ *@param geoShape is the shape.
+ *@return the relationship.
+ */
+ protected int isShapeInsideGeoAreaShape(final GeoShape geoShape) {
+ boolean foundOutside = false;
+ boolean foundInside = false;
+ for (GeoPoint p : geoShape.getEdgePoints()) {
+ if (isWithin(p)) {
+ foundInside = true;
+ } else {
+ foundOutside = true;
+ }
+ if (foundInside && foundOutside) {
+ return SOME_INSIDE;
+ }
+ }
+ if (!foundInside && !foundOutside)
+ return NONE_INSIDE;
+ if (foundInside && !foundOutside)
+ return ALL_INSIDE;
+ if (foundOutside && !foundInside)
+ return NONE_INSIDE;
+ return SOME_INSIDE;
+ }
+
+ /** Determine the relationship between the GeoAreaShape's edgepoints and the
+ * provided shape.
+ *@param geoshape is the shape.
+ *@return the relationship.
+ */
+ protected int isGeoAreaShapeInsideShape(final GeoShape geoshape) {
+ boolean foundOutside = false;
+ boolean foundInside = false;
+ for (GeoPoint p : getEdgePoints()) {
+ if (geoshape.isWithin(p)) {
+ foundInside = true;
+ } else {
+ foundOutside = true;
+ }
+ if (foundInside && foundOutside) {
+ return SOME_INSIDE;
+ }
+ }
+ if (!foundInside && !foundOutside)
+ return NONE_INSIDE;
+ if (foundInside && !foundOutside)
+ return ALL_INSIDE;
+ if (foundOutside && !foundInside)
+ return NONE_INSIDE;
+ return SOME_INSIDE;
+ }
+
+ @Override
+ public int getRelationship(GeoShape geoShape) {
+ final int insideGeoAreaShape = isShapeInsideGeoAreaShape(geoShape);
+ if (insideGeoAreaShape == SOME_INSIDE) {
+ return GeoArea.OVERLAPS;
+ }
+
+ final int insideShape = isGeoAreaShapeInsideShape(geoShape);
+ if (insideShape == SOME_INSIDE) {
+ return GeoArea.OVERLAPS;
+ }
+
+ if (insideGeoAreaShape == ALL_INSIDE && insideShape==ALL_INSIDE) {
+ return GeoArea.OVERLAPS;
+ }
+
+ if (intersects(geoShape)){
+ return GeoArea.OVERLAPS;
+ }
+
+ if (insideGeoAreaShape == ALL_INSIDE) {
+ return GeoArea.WITHIN;
+ }
+
+ if (insideShape==ALL_INSIDE) {
+ return GeoArea.CONTAINS;
+ }
+
+ return GeoArea.DISJOINT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseBBox.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseBBox.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseBBox.java
index ba92cc2..59562be 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseBBox.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseBBox.java
@@ -22,7 +22,7 @@ package org.apache.lucene.spatial3d.geom;
*
* @lucene.internal
*/
-abstract class GeoBaseBBox extends GeoBaseMembershipShape implements GeoBBox {
+abstract class GeoBaseBBox extends GeoBaseAreaShape implements GeoBBox {
/** Construct, given planet model.
*@param planetModel is the planet model.
@@ -31,42 +31,6 @@ abstract class GeoBaseBBox extends GeoBaseMembershipShape implements GeoBBox {
super(planetModel);
}
- // Signals for relationship of edge points to shape
-
- /** All edgepoints inside shape */
- protected final static int ALL_INSIDE = 0;
- /** Some edgepoints inside shape */
- protected final static int SOME_INSIDE = 1;
- /** No edgepoints inside shape */
- protected final static int NONE_INSIDE = 2;
-
- /** Determine the relationship between this BBox and the provided
- * shape's edgepoints.
- *@param path is the shape.
- *@return the relationship.
- */
- protected int isShapeInsideBBox(final GeoShape path) {
- final GeoPoint[] pathPoints = path.getEdgePoints();
- boolean foundOutside = false;
- boolean foundInside = false;
- for (GeoPoint p : pathPoints) {
- if (isWithin(p)) {
- foundInside = true;
- } else {
- foundOutside = true;
- }
- if (foundInside && foundOutside) {
- return SOME_INSIDE;
- }
- }
- if (!foundInside && !foundOutside)
- return NONE_INSIDE;
- if (foundInside && !foundOutside)
- return ALL_INSIDE;
- if (foundOutside && !foundInside)
- return NONE_INSIDE;
- return SOME_INSIDE;
- }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseDistanceShape.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseDistanceShape.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseDistanceShape.java
index 82e811a..d7be2ab 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseDistanceShape.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBaseDistanceShape.java
@@ -22,7 +22,7 @@ package org.apache.lucene.spatial3d.geom;
*
* @lucene.experimental
*/
-public abstract class GeoBaseDistanceShape extends GeoBaseMembershipShape implements GeoDistanceShape {
+public abstract class GeoBaseDistanceShape extends GeoBaseAreaShape implements GeoDistanceShape {
/** Constructor.
*@param planetModel is the planet model to use.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBasePolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBasePolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBasePolygon.java
index 08c0634..7fe8c98 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBasePolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBasePolygon.java
@@ -21,7 +21,7 @@ package org.apache.lucene.spatial3d.geom;
*
* @lucene.internal
*/
-abstract class GeoBasePolygon extends GeoBaseMembershipShape implements GeoPolygon {
+abstract class GeoBasePolygon extends GeoBaseAreaShape implements GeoPolygon {
/** Constructor.
*@param planetModel is the planet model to use.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
index 7f8f649..6bd66d4 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
@@ -369,6 +369,32 @@ class GeoComplexPolygon extends GeoBasePolygon {
return true;
}
+ @Override
+ public boolean intersects(GeoShape geoShape) {
+ // Create the intersector
+ final EdgeIterator intersector = new IntersectorShapeIterator(geoShape);
+ // First, compute the bounds for the the plane
+ final XYZBounds xyzBounds = new XYZBounds();
+ geoShape.getBounds(xyzBounds);
+
+ // Figure out which tree likely works best
+ final double xDelta = xyzBounds.getMaximumX() - xyzBounds.getMinimumX();
+ final double yDelta = xyzBounds.getMaximumY() - xyzBounds.getMinimumY();
+ final double zDelta = xyzBounds.getMaximumZ() - xyzBounds.getMinimumZ();
+ // Select the smallest range
+ if (xDelta <= yDelta && xDelta <= zDelta) {
+ // Drill down in x
+ return !xTree.traverse(intersector, xyzBounds.getMinimumX(), xyzBounds.getMaximumX());
+ } else if (yDelta <= xDelta && yDelta <= zDelta) {
+ // Drill down in y
+ return !yTree.traverse(intersector, xyzBounds.getMinimumY(), xyzBounds.getMaximumY());
+ } else if (zDelta <= xDelta && zDelta <= yDelta) {
+ // Drill down in z
+ return !zTree.traverse(intersector, xyzBounds.getMinimumZ(), xyzBounds.getMaximumZ());
+ }
+ return true;
+ }
+
@Override
public void getBounds(Bounds bounds) {
@@ -691,7 +717,24 @@ class GeoComplexPolygon extends GeoBasePolygon {
}
}
-
+
+
+ /** Assess whether edge intersects the provided shape.
+ */
+ private class IntersectorShapeIterator implements EdgeIterator {
+
+ private final GeoShape shape;
+
+ public IntersectorShapeIterator(final GeoShape shape) {
+ this.shape = shape;
+ }
+
+ @Override
+ public boolean matches(final Edge edge) {
+ return !shape.intersects(edge.plane, edge.notablePoints, edge.startPlane, edge.endPlane);
+ }
+ }
+
/** Count the number of verifiable edge crossings.
*/
private class LinearCrossingEdgeIterator implements EdgeIterator {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositeAreaShape.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositeAreaShape.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositeAreaShape.java
new file mode 100644
index 0000000..c7ad81d
--- /dev/null
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositeAreaShape.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.spatial3d.geom;
+
+/**
+ * GeoCompositeAreShape is a set of GeoAreaShape's, treated as a unit.
+ *
+ * @lucene.experimental
+ */
+public class GeoCompositeAreaShape extends GeoCompositeMembershipShape implements GeoAreaShape {
+
+ /**
+ * Add a shape to the composite. It throw an IllegalArgumentException
+ * if the shape is not a GeoAreaShape
+ *@param shape is the shape to add.
+ */
+ @Override
+ public void addShape(final GeoMembershipShape shape) {
+ if (!(shape instanceof GeoAreaShape)){
+ throw new IllegalArgumentException("GeoCompositeAreaShape must be composed of GeoAreaShapes");
+ }
+ shapes.add(shape);
+ }
+
+ public boolean intersects(GeoShape geoShape){
+ for(GeoShape inShape : shapes){
+ if (((GeoAreaShape)inShape).intersects(geoShape)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /** All edgepoints inside shape */
+ protected final static int ALL_INSIDE = 0;
+ /** Some edgepoints inside shape */
+ protected final static int SOME_INSIDE = 1;
+ /** No edgepoints inside shape */
+ protected final static int NONE_INSIDE = 2;
+
+ /** Determine the relationship between the GeoAreShape and the
+ * shape's edgepoints.
+ *@param geoShape is the shape.
+ *@return the relationship.
+ */
+ protected int isShapeInsideGeoAreaShape(final GeoShape geoShape) {
+ boolean foundOutside = false;
+ boolean foundInside = false;
+ for (GeoPoint p : geoShape.getEdgePoints()) {
+ if (isWithin(p)) {
+ foundInside = true;
+ } else {
+ foundOutside = true;
+ }
+ if (foundInside && foundOutside) {
+ return SOME_INSIDE;
+ }
+ }
+ if (!foundInside && !foundOutside)
+ return NONE_INSIDE;
+ if (foundInside && !foundOutside)
+ return ALL_INSIDE;
+ if (foundOutside && !foundInside)
+ return NONE_INSIDE;
+ return SOME_INSIDE;
+ }
+
+ /** Determine the relationship between the GeoAreShape's edgepoints and the
+ * provided shape.
+ *@param geoshape is the shape.
+ *@return the relationship.
+ */
+ protected int isGeoAreaShapeInsideShape(final GeoShape geoshape) {
+ boolean foundOutside = false;
+ boolean foundInside = false;
+ for (GeoPoint p : getEdgePoints()) {
+ if (geoshape.isWithin(p)) {
+ foundInside = true;
+ } else {
+ foundOutside = true;
+ }
+ if (foundInside && foundOutside) {
+ return SOME_INSIDE;
+ }
+ }
+ if (!foundInside && !foundOutside)
+ return NONE_INSIDE;
+ if (foundInside && !foundOutside)
+ return ALL_INSIDE;
+ if (foundOutside && !foundInside)
+ return NONE_INSIDE;
+ return SOME_INSIDE;
+ }
+
+ @Override
+ public int getRelationship(GeoShape geoShape) {
+ final int insideGeoAreaShape = isShapeInsideGeoAreaShape(geoShape);
+ if (insideGeoAreaShape == SOME_INSIDE) {
+ return GeoArea.OVERLAPS;
+ }
+
+ final int insideShape = isGeoAreaShapeInsideShape(geoShape);
+ if (insideShape == SOME_INSIDE) {
+ return GeoArea.OVERLAPS;
+ }
+
+ if (insideGeoAreaShape == ALL_INSIDE && insideShape==ALL_INSIDE) {
+ return GeoArea.OVERLAPS;
+ }
+
+ if (intersects(geoShape)){
+ return GeoArea.OVERLAPS;
+ }
+
+ if (insideGeoAreaShape == ALL_INSIDE) {
+ return GeoArea.WITHIN;
+ }
+
+ if (insideShape==ALL_INSIDE) {
+ return GeoArea.CONTAINS;
+ }
+
+ return GeoArea.DISJOINT;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositeMembershipShape.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositeMembershipShape.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositeMembershipShape.java
index 6600a34..24428f9 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositeMembershipShape.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositeMembershipShape.java
@@ -17,6 +17,7 @@
package org.apache.lucene.spatial3d.geom;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
/**
@@ -57,7 +58,11 @@ public class GeoCompositeMembershipShape implements GeoMembershipShape {
@Override
public GeoPoint[] getEdgePoints() {
- return shapes.get(0).getEdgePoints();
+ List<GeoPoint> edgePoints = new ArrayList<>();
+ for(int i=0;i<shapes.size();i++){
+ edgePoints.addAll(Arrays.asList(shapes.get(i).getEdgePoints()));
+ }
+ return edgePoints.toArray(new GeoPoint[edgePoints.size()]);
}
@Override
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositePolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositePolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositePolygon.java
index 920d3fb..be373ed 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositePolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoCompositePolygon.java
@@ -21,7 +21,7 @@ package org.apache.lucene.spatial3d.geom;
*
* @lucene.experimental
*/
-public class GeoCompositePolygon extends GeoCompositeMembershipShape implements GeoPolygon {
+public class GeoCompositePolygon extends GeoCompositeAreaShape implements GeoPolygon {
/** Constructor.
*/
public GeoCompositePolygon() {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
index e2a4c1e..75fecc8 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
@@ -366,6 +366,27 @@ class GeoConcavePolygon extends GeoBasePolygon {
return false;
}
+ @Override
+ public boolean intersects(GeoShape geoShape) {
+ for (int edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
+ final SidedPlane edge = edges[edgeIndex];
+ final GeoPoint[] points = this.notableEdgePoints[edgeIndex];
+ if (!isInternalEdges.get(edgeIndex)) {
+ if (geoShape.intersects(edge, points, eitherBounds.get(edge))) {
+ return true;
+ }
+ }
+ }
+ if (holes != null) {
+ for (final GeoPolygon hole : holes) {
+ if (hole.intersects(geoShape)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
/** A membership implementation representing polygon edges that must apply.
*/
protected static class EitherBound implements Membership {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
index 6bd0aad..bf75e3b 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
@@ -356,6 +356,27 @@ class GeoConvexPolygon extends GeoBasePolygon {
return false;
}
+ @Override
+ public boolean intersects(GeoShape shape) {
+ for (int edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
+ final SidedPlane edge = edges[edgeIndex];
+ final GeoPoint[] points = this.notableEdgePoints[edgeIndex];
+ if (!isInternalEdges.get(edgeIndex)) {
+ if (shape.intersects(edge, points, eitherBounds.get(edge))) {
+ return true;
+ }
+ }
+ }
+ if (holes != null) {
+ for (final GeoPolygon hole : holes) {
+ if (hole.intersects(shape)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
/** A membership implementation representing polygon edges that must apply.
*/
protected static class EitherBound implements Membership {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateHorizontalLine.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateHorizontalLine.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateHorizontalLine.java
index 927fbdc..9518180 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateHorizontalLine.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateHorizontalLine.java
@@ -155,6 +155,11 @@ class GeoDegenerateHorizontalLine extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(plane, planePoints, leftPlane, rightPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds.addHorizontalPlane(planetModel, latitude, plane, leftPlane, rightPlane)
@@ -164,7 +169,7 @@ class GeoDegenerateHorizontalLine extends GeoBaseBBox {
@Override
public int getRelationship(final GeoShape path) {
//System.err.println("getting relationship between "+this+" and "+path);
- if (path.intersects(plane, planePoints, leftPlane, rightPlane)) {
+ if (intersects(path)) {
//System.err.println(" overlaps");
return OVERLAPS;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLatitudeZone.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLatitudeZone.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLatitudeZone.java
index ea6bb57..fc6b234 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLatitudeZone.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLatitudeZone.java
@@ -86,6 +86,11 @@ class GeoDegenerateLatitudeZone extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(plane, planePoints);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds.noLongitudeBound()
@@ -98,7 +103,7 @@ class GeoDegenerateLatitudeZone extends GeoBaseBBox {
// work with no area endpoints. So we rely entirely on intersections.
//System.out.println("Got here! latitude="+latitude+" path="+path);
- if (path.intersects(plane, planePoints)) {
+ if (intersects(path)) {
return OVERLAPS;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLongitudeSlice.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLongitudeSlice.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLongitudeSlice.java
index 09f468c..e610ff4 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLongitudeSlice.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateLongitudeSlice.java
@@ -97,6 +97,11 @@ class GeoDegenerateLongitudeSlice extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(plane, planePoints, boundingPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds
@@ -107,7 +112,7 @@ class GeoDegenerateLongitudeSlice extends GeoBaseBBox {
@Override
public int getRelationship(final GeoShape path) {
// Look for intersections.
- if (path.intersects(plane, planePoints, boundingPlane))
+ if (intersects(path))
return OVERLAPS;
if (path.isWithin(interiorPoint))
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePoint.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePoint.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePoint.java
index ab08579..2860757 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePoint.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePoint.java
@@ -67,6 +67,11 @@ class GeoDegeneratePoint extends GeoPoint implements GeoBBox, GeoCircle {
}
@Override
+ public boolean intersects(GeoShape geoShape) {
+ return false;
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
bounds.addPoint(this);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateVerticalLine.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateVerticalLine.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateVerticalLine.java
index dff53b4..c8acf78 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateVerticalLine.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegenerateVerticalLine.java
@@ -145,6 +145,11 @@ public class GeoDegenerateVerticalLine extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(plane, planePoints, boundingPlane, topPlane, bottomPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds.addVerticalPlane(planetModel, longitude, plane, boundingPlane, topPlane, bottomPlane)
@@ -154,7 +159,7 @@ public class GeoDegenerateVerticalLine extends GeoBaseBBox {
@Override
public int getRelationship(final GeoShape path) {
//System.err.println(this+" relationship to "+path);
- if (path.intersects(plane, planePoints, boundingPlane, topPlane, bottomPlane)) {
+ if (intersects(path)) {
//System.err.println(" overlaps");
return OVERLAPS;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDistanceShape.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDistanceShape.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDistanceShape.java
index ebd433f..c49ed30 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDistanceShape.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDistanceShape.java
@@ -22,7 +22,7 @@ package org.apache.lucene.spatial3d.geom;
*
* @lucene.experimental
*/
-public interface GeoDistanceShape extends GeoMembershipShape, GeoDistance {
+public interface GeoDistanceShape extends GeoAreaShape, GeoDistance {
/**
* Compute a bound based on a provided distance measure.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLatitudeZone.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLatitudeZone.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLatitudeZone.java
index 14618f5..716efb5 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLatitudeZone.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLatitudeZone.java
@@ -120,6 +120,12 @@ class GeoLatitudeZone extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(topPlane, planePoints, bottomPlane) ||
+ geoShape.intersects(bottomPlane, planePoints, topPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds.noLongitudeBound()
@@ -128,46 +134,6 @@ class GeoLatitudeZone extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE)
- return OVERLAPS;
-
- final boolean topBoundaryInsideShape = path.isWithin(topBoundaryPoint);
- final boolean bottomBoundaryInsideShape = path.isWithin(bottomBoundaryPoint);
-
- if (topBoundaryInsideShape && !bottomBoundaryInsideShape ||
- !topBoundaryInsideShape && bottomBoundaryInsideShape)
- return OVERLAPS;
-
- final boolean insideShape = topBoundaryInsideShape && bottomBoundaryInsideShape;
-
- if (insideRectangle == ALL_INSIDE && insideShape)
- return OVERLAPS;
-
- // Second, the shortcut of seeing whether endpoints are in/out is not going to
- // work with no area endpoints. So we rely entirely on intersections.
-
- if (path.intersects(topPlane, planePoints, bottomPlane) ||
- path.intersects(bottomPlane, planePoints, topPlane))
- return OVERLAPS;
-
- // There is another case for latitude zones only. This is when the boundaries of the shape all fit
- // within the zone, but the shape includes areas outside the zone crossing a pole.
- // In this case, the above "overlaps" check is insufficient. We also need to check a point on either boundary
- // whether it is within the shape. If both such points are within, then CONTAINS is the right answer. If
- // one such point is within, then OVERLAPS is the right answer.
-
- if (insideShape)
- return CONTAINS;
-
- if (insideRectangle == ALL_INSIDE)
- return WITHIN;
-
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
final double topDistance = distanceStyle.computeDistance(planetModel, topPlane, x,y,z, bottomPlane);
final double bottomDistance = distanceStyle.computeDistance(planetModel, bottomPlane, x,y,z, topPlane);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
index 294d4e8..fc21a21 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
@@ -128,6 +128,12 @@ class GeoLongitudeSlice extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(leftPlane, planePoints, rightPlane) ||
+ geoShape.intersects(rightPlane, planePoints, leftPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds
@@ -139,33 +145,6 @@ class GeoLongitudeSlice extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE)
- return OVERLAPS;
-
- final boolean insideShape = path.isWithin(planetModel.NORTH_POLE);
-
- if (insideRectangle == ALL_INSIDE && insideShape)
- return OVERLAPS;
-
- if (path.intersects(leftPlane, planePoints, rightPlane) ||
- path.intersects(rightPlane, planePoints, leftPlane)) {
- return OVERLAPS;
- }
-
- if (insideRectangle == ALL_INSIDE) {
- return WITHIN;
- }
-
- if (insideShape) {
- return CONTAINS;
- }
-
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
final double leftDistance = distanceStyle.computeDistance(planetModel, leftPlane, x,y,z, rightPlane);
final double rightDistance = distanceStyle.computeDistance(planetModel, rightPlane, x,y,z, leftPlane);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthLatitudeZone.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthLatitudeZone.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthLatitudeZone.java
index 2acfc4e..7c3ea96 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthLatitudeZone.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthLatitudeZone.java
@@ -99,6 +99,12 @@ class GeoNorthLatitudeZone extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return
+ geoShape.intersects(bottomPlane, planePoints);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds
@@ -106,38 +112,6 @@ class GeoNorthLatitudeZone extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE)
- return OVERLAPS;
-
- final boolean insideShape = path.isWithin(bottomBoundaryPoint);
-
- if (insideRectangle == ALL_INSIDE && insideShape)
- return OVERLAPS;
-
- // Second, the shortcut of seeing whether endpoints are in/out is not going to
- // work with no area endpoints. So we rely entirely on intersections.
-
- if (path.intersects(bottomPlane, planePoints))
- return OVERLAPS;
-
- // There is another case for latitude zones only. This is when the boundaries of the shape all fit
- // within the zone, but the shape includes areas outside the zone crossing a pole.
- // In this case, the above "overlaps" check is insufficient. We also need to check a point on either boundary
- // whether it is within the shape. If both such points are within, then CONTAINS is the right answer. If
- // one such point is within, then OVERLAPS is the right answer.
-
- if (insideShape)
- return CONTAINS;
-
- if (insideRectangle == ALL_INSIDE)
- return WITHIN;
-
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
return distanceStyle.computeDistance(planetModel, bottomPlane, x,y,z);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
index 27422d2..2a1b7c5 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
@@ -175,6 +175,14 @@ class GeoNorthRectangle extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return
+ geoShape.intersects(bottomPlane, bottomPlanePoints, leftPlane, rightPlane) ||
+ geoShape.intersects(leftPlane, leftPlanePoints, rightPlane, bottomPlane) ||
+ geoShape.intersects(rightPlane, rightPlanePoints, leftPlane, bottomPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds
@@ -186,43 +194,6 @@ class GeoNorthRectangle extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- //System.err.println(this+" getrelationship with "+path);
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE) {
- //System.err.println(" some inside");
- return OVERLAPS;
- }
-
- final boolean insideShape = path.isWithin(planetModel.NORTH_POLE);
-
- if (insideRectangle == ALL_INSIDE && insideShape) {
- //System.err.println(" inside of each other");
- return OVERLAPS;
- }
-
- if (
- path.intersects(bottomPlane, bottomPlanePoints, leftPlane, rightPlane) ||
- path.intersects(leftPlane, leftPlanePoints, bottomPlane, rightPlane) ||
- path.intersects(rightPlane, rightPlanePoints, leftPlane, bottomPlane)) {
- //System.err.println(" edges intersect");
- return OVERLAPS;
- }
-
- if (insideRectangle == ALL_INSIDE) {
- //System.err.println(" shape inside rectangle");
- return WITHIN;
- }
-
- if (insideShape) {
- //System.err.println(" shape contains rectangle");
- return CONTAINS;
- }
- //System.err.println(" disjoint");
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
final double bottomDistance = distanceStyle.computeDistance(planetModel, bottomPlane, x,y,z, leftPlane, rightPlane);
final double leftDistance = distanceStyle.computeDistance(planetModel, leftPlane, x,y,z, rightPlane, bottomPlane);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygon.java
index 742bdf8..9125d14 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygon.java
@@ -21,6 +21,6 @@ package org.apache.lucene.spatial3d.geom;
*
* @lucene.experimental
*/
-public interface GeoPolygon extends GeoMembershipShape {
+public interface GeoPolygon extends GeoAreaShape {
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
index 3d0a97d..faf2952 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
@@ -197,6 +197,14 @@ class GeoRectangle extends GeoBaseBBox {
}
@Override
+ public boolean intersects(GeoShape geoShape) {
+ return geoShape.intersects(topPlane, topPlanePoints, bottomPlane, leftPlane, rightPlane) ||
+ geoShape.intersects(bottomPlane, bottomPlanePoints, topPlane, leftPlane, rightPlane) ||
+ geoShape.intersects(leftPlane, leftPlanePoints, rightPlane, topPlane, bottomPlane) ||
+ geoShape.intersects(rightPlane, rightPlanePoints, leftPlane, topPlane, bottomPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds.addHorizontalPlane(planetModel, topLat, topPlane, bottomPlane, leftPlane, rightPlane)
@@ -208,43 +216,6 @@ class GeoRectangle extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- //System.err.println(this+" getrelationship with "+path);
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE) {
- //System.err.println(" some inside");
- return OVERLAPS;
- }
-
- final boolean insideShape = path.isWithin(ULHC);
-
- if (insideRectangle == ALL_INSIDE && insideShape) {
- //System.err.println(" inside of each other");
- return OVERLAPS;
- }
-
- if (path.intersects(topPlane, topPlanePoints, bottomPlane, leftPlane, rightPlane) ||
- path.intersects(bottomPlane, bottomPlanePoints, topPlane, leftPlane, rightPlane) ||
- path.intersects(leftPlane, leftPlanePoints, topPlane, bottomPlane, rightPlane) ||
- path.intersects(rightPlane, rightPlanePoints, leftPlane, topPlane, bottomPlane)) {
- //System.err.println(" edges intersect");
- return OVERLAPS;
- }
-
- if (insideRectangle == ALL_INSIDE) {
- //System.err.println(" shape inside rectangle");
- return WITHIN;
- }
-
- if (insideShape) {
- //System.err.println(" shape contains rectangle");
- return CONTAINS;
- }
- //System.err.println(" disjoint");
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
final double topDistance = distanceStyle.computeDistance(planetModel, topPlane, x,y,z, bottomPlane, leftPlane, rightPlane);
final double bottomDistance = distanceStyle.computeDistance(planetModel, bottomPlane, x,y,z, topPlane, leftPlane, rightPlane);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthLatitudeZone.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthLatitudeZone.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthLatitudeZone.java
index c915c24..acb7cb0 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthLatitudeZone.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthLatitudeZone.java
@@ -102,6 +102,11 @@ class GeoSouthLatitudeZone extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(topPlane, planePoints);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds
@@ -109,38 +114,6 @@ class GeoSouthLatitudeZone extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE)
- return OVERLAPS;
-
- final boolean insideShape = path.isWithin(topBoundaryPoint);
-
- if (insideRectangle == ALL_INSIDE && insideShape)
- return OVERLAPS;
-
- // Second, the shortcut of seeing whether endpoints are in/out is not going to
- // work with no area endpoints. So we rely entirely on intersections.
-
- if (path.intersects(topPlane, planePoints))
- return OVERLAPS;
-
- // There is another case for latitude zones only. This is when the boundaries of the shape all fit
- // within the zone, but the shape includes areas outside the zone crossing a pole.
- // In this case, the above "overlaps" check is insufficient. We also need to check a point on either boundary
- // whether it is within the shape. If both such points are within, then CONTAINS is the right answer. If
- // one such point is within, then OVERLAPS is the right answer.
-
- if (insideShape)
- return CONTAINS;
-
- if (insideRectangle == ALL_INSIDE)
- return WITHIN;
-
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
return distanceStyle.computeDistance(planetModel, topPlane, x,y,z);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
index ed380e1..f75fc8c 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
@@ -173,6 +173,13 @@ class GeoSouthRectangle extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(topPlane, topPlanePoints, leftPlane, rightPlane) ||
+ geoShape.intersects(leftPlane, leftPlanePoints, rightPlane, topPlane) ||
+ geoShape.intersects(rightPlane, rightPlanePoints, leftPlane, topPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds
@@ -184,42 +191,6 @@ class GeoSouthRectangle extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- //System.err.println(this+" getrelationship with "+path);
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE) {
- //System.err.println(" some inside");
- return OVERLAPS;
- }
-
- final boolean insideShape = path.isWithin(planetModel.SOUTH_POLE);
-
- if (insideRectangle == ALL_INSIDE && insideShape) {
- //System.err.println(" inside of each other");
- return OVERLAPS;
- }
-
- if (path.intersects(topPlane, topPlanePoints, leftPlane, rightPlane) ||
- path.intersects(leftPlane, leftPlanePoints, topPlane, rightPlane) ||
- path.intersects(rightPlane, rightPlanePoints, leftPlane, topPlane)) {
- //System.err.println(" edges intersect");
- return OVERLAPS;
- }
-
- if (insideRectangle == ALL_INSIDE) {
- //System.err.println(" shape inside rectangle");
- return WITHIN;
- }
-
- if (insideShape) {
- //System.err.println(" shape contains rectangle");
- return CONTAINS;
- }
- //System.err.println(" disjoint");
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
final double topDistance = distanceStyle.computeDistance(planetModel, topPlane, x,y,z, leftPlane, rightPlane);
final double leftDistance = distanceStyle.computeDistance(planetModel, leftPlane, x,y,z, rightPlane, topPlane);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java
index 06bef00..ec83edf 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java
@@ -140,6 +140,14 @@ class GeoStandardCircle extends GeoBaseCircle {
}
@Override
+ public boolean intersects(GeoShape geoShape) {
+ if (circlePlane == null) {
+ return false;
+ }
+ return geoShape.intersects(circlePlane, circlePoints);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
if (circlePlane == null) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
index 51c5078..b3b6594 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
@@ -289,6 +289,23 @@ class GeoStandardPath extends GeoBasePath {
}
@Override
+ public boolean intersects(GeoShape geoShape) {
+ for (final SegmentEndpoint pathPoint : endPoints) {
+ if (pathPoint.intersects(geoShape)) {
+ return true;
+ }
+ }
+
+ for (final PathSegment pathSegment : segments) {
+ if (pathSegment.intersects(geoShape)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
// For building bounds, order matters. We want to traverse
@@ -549,6 +566,17 @@ class GeoStandardPath extends GeoBasePath {
return circlePlane.intersects(planetModel, p, notablePoints, this.notablePoints, bounds, this.cutoffPlanes);
}
+ /** Determine if this endpoint intersects a GeoShape.
+ *@param geoShape is the GeoShape.
+ *@return true if there is shape intersect this endpoint.
+ */
+ public boolean intersects(final GeoShape geoShape) {
+ //System.err.println(" looking for intersection between plane "+p+" and circle "+circlePlane+" on proper side of "+cutoffPlanes+" within "+bounds);
+ if (circlePlane == null)
+ return false;
+ return geoShape.intersects(circlePlane, this.notablePoints, this.cutoffPlanes);
+ }
+
/** Get the bounds for a segment endpoint.
*@param planetModel is the planet model.
*@param bounds are the bounds to be modified.
@@ -799,6 +827,15 @@ class GeoStandardPath extends GeoBasePath {
lowerConnectingPlane.intersects(planetModel, p, notablePoints, lowerConnectingPlanePoints, bounds, upperConnectingPlane, startCutoffPlane, endCutoffPlane);
}
+ /** Determine if this endpoint intersects a specified GeoShape.
+ *@param geoShape is the GeoShape.
+ *@return true if there GeoShape intersects this endpoint.
+ */
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(upperConnectingPlane, upperConnectingPlanePoints, lowerConnectingPlane, startCutoffPlane, endCutoffPlane) ||
+ geoShape.intersects(lowerConnectingPlane, lowerConnectingPlanePoints, upperConnectingPlane, startCutoffPlane, endCutoffPlane);
+ }
+
/** Get the bounds for a segment endpoint.
*@param planetModel is the planet model.
*@param bounds are the bounds to be modified.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideDegenerateHorizontalLine.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideDegenerateHorizontalLine.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideDegenerateHorizontalLine.java
index fe93473..90d35ee 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideDegenerateHorizontalLine.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideDegenerateHorizontalLine.java
@@ -166,6 +166,13 @@ class GeoWideDegenerateHorizontalLine extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ // Right and left bounds are essentially independent hemispheres; crossing into the wrong part of one
+ // requires crossing into the right part of the other. So intersection can ignore the left/right bounds.
+ return geoShape.intersects(plane, planePoints, eitherBound);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds.isWide()
@@ -176,7 +183,7 @@ class GeoWideDegenerateHorizontalLine extends GeoBaseBBox {
@Override
public int getRelationship(final GeoShape path) {
- if (path.intersects(plane, planePoints, eitherBound)) {
+ if (intersects(path)) {
return OVERLAPS;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java
index 705d961..e15c275 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java
@@ -140,6 +140,14 @@ class GeoWideLongitudeSlice extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ // Right and left bounds are essentially independent hemispheres; crossing into the wrong part of one
+ // requires crossing into the right part of the other. So intersection can ignore the left/right bounds.
+ return geoShape.intersects(leftPlane, planePoints) ||
+ geoShape.intersects(rightPlane, planePoints);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds.isWide()
@@ -151,30 +159,6 @@ class GeoWideLongitudeSlice extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE)
- return OVERLAPS;
-
- final boolean insideShape = path.isWithin(planetModel.NORTH_POLE);
-
- if (insideRectangle == ALL_INSIDE && insideShape)
- return OVERLAPS;
-
- if (path.intersects(leftPlane, planePoints) ||
- path.intersects(rightPlane, planePoints))
- return OVERLAPS;
-
- if (insideRectangle == ALL_INSIDE)
- return WITHIN;
-
- if (insideShape)
- return CONTAINS;
-
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
// Because the rectangle exceeds 180 degrees, it is safe to compute the horizontally
// unbounded distance to both the left and the right and only take the minimum of the two.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideNorthRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideNorthRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideNorthRectangle.java
index 849d4e9..5672003 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideNorthRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideNorthRectangle.java
@@ -177,6 +177,16 @@ class GeoWideNorthRectangle extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ // Right and left bounds are essentially independent hemispheres; crossing into the wrong part of one
+ // requires crossing into the right part of the other. So intersection can ignore the left/right bounds.
+ return
+ geoShape.intersects(bottomPlane, bottomPlanePoints, eitherBound) ||
+ geoShape.intersects(leftPlane, leftPlanePoints, bottomPlane) ||
+ geoShape.intersects(rightPlane, rightPlanePoints, bottomPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds.isWide()
@@ -188,44 +198,6 @@ class GeoWideNorthRectangle extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- //System.err.println(this+" comparing to "+path);
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE) {
- //System.err.println(" some inside");
- return OVERLAPS;
- }
-
- final boolean insideShape = path.isWithin(planetModel.NORTH_POLE);
-
- if (insideRectangle == ALL_INSIDE && insideShape) {
- //System.err.println(" both inside each other");
- return OVERLAPS;
- }
-
- if (
- path.intersects(bottomPlane, bottomPlanePoints, eitherBound) ||
- path.intersects(leftPlane, leftPlanePoints, bottomPlane) ||
- path.intersects(rightPlane, rightPlanePoints, bottomPlane)) {
- //System.err.println(" edges intersect");
- return OVERLAPS;
- }
-
- if (insideRectangle == ALL_INSIDE) {
- //System.err.println(" shape inside rectangle");
- return WITHIN;
- }
-
- if (insideShape) {
- //System.err.println(" rectangle inside shape");
- return CONTAINS;
- }
-
- //System.err.println(" disjoint");
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
final double bottomDistance = distanceStyle.computeDistance(planetModel, bottomPlane, x,y,z, eitherBound);
// Because the rectangle exceeds 180 degrees, it is safe to compute the horizontally
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideRectangle.java
index 53c8c59..43b9bc7 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideRectangle.java
@@ -205,6 +205,14 @@ class GeoWideRectangle extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(topPlane, topPlanePoints, bottomPlane, eitherBound) ||
+ geoShape.intersects(bottomPlane, bottomPlanePoints, topPlane, eitherBound) ||
+ geoShape.intersects(leftPlane, leftPlanePoints, topPlane, bottomPlane) ||
+ geoShape.intersects(rightPlane, rightPlanePoints, topPlane, bottomPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds.isWide()
@@ -217,44 +225,6 @@ class GeoWideRectangle extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- //System.err.println(this+" comparing to "+path);
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE) {
- //System.err.println(" some inside");
- return OVERLAPS;
- }
-
- final boolean insideShape = path.isWithin(ULHC);
-
- if (insideRectangle == ALL_INSIDE && insideShape) {
- //System.err.println(" both inside each other");
- return OVERLAPS;
- }
-
- if (path.intersects(topPlane, topPlanePoints, bottomPlane, eitherBound) ||
- path.intersects(bottomPlane, bottomPlanePoints, topPlane, eitherBound) ||
- path.intersects(leftPlane, leftPlanePoints, topPlane, bottomPlane) ||
- path.intersects(rightPlane, rightPlanePoints, topPlane, bottomPlane)) {
- //System.err.println(" edges intersect");
- return OVERLAPS;
- }
-
- if (insideRectangle == ALL_INSIDE) {
- //System.err.println(" shape inside rectangle");
- return WITHIN;
- }
-
- if (insideShape) {
- //System.err.println(" rectangle inside shape");
- return CONTAINS;
- }
-
- //System.err.println(" disjoint");
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
final double topDistance = distanceStyle.computeDistance(planetModel, topPlane, x,y,z, bottomPlane, eitherBound);
final double bottomDistance = distanceStyle.computeDistance(planetModel, bottomPlane, x,y,z, topPlane, eitherBound);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideSouthRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideSouthRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideSouthRectangle.java
index 29d89c5..ea60322 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideSouthRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideSouthRectangle.java
@@ -176,6 +176,13 @@ class GeoWideSouthRectangle extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return geoShape.intersects(topPlane, topPlanePoints, eitherBound) ||
+ geoShape.intersects(leftPlane, leftPlanePoints, topPlane) ||
+ geoShape.intersects(rightPlane, rightPlanePoints, topPlane);
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
bounds.isWide()
@@ -187,43 +194,6 @@ class GeoWideSouthRectangle extends GeoBaseBBox {
}
@Override
- public int getRelationship(final GeoShape path) {
- //System.err.println(this+" comparing to "+path);
- final int insideRectangle = isShapeInsideBBox(path);
- if (insideRectangle == SOME_INSIDE) {
- //System.err.println(" some inside");
- return OVERLAPS;
- }
-
- final boolean insideShape = path.isWithin(planetModel.SOUTH_POLE);
-
- if (insideRectangle == ALL_INSIDE && insideShape) {
- //System.err.println(" both inside each other");
- return OVERLAPS;
- }
-
- if (path.intersects(topPlane, topPlanePoints, eitherBound) ||
- path.intersects(leftPlane, leftPlanePoints, topPlane) ||
- path.intersects(rightPlane, rightPlanePoints, topPlane)) {
- //System.err.println(" edges intersect");
- return OVERLAPS;
- }
-
- if (insideRectangle == ALL_INSIDE) {
- //System.err.println(" shape inside rectangle");
- return WITHIN;
- }
-
- if (insideShape) {
- //System.err.println(" rectangle inside shape");
- return CONTAINS;
- }
-
- //System.err.println(" disjoint");
- return DISJOINT;
- }
-
- @Override
protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) {
final double topDistance = distanceStyle.computeDistance(planetModel, topPlane, x,y,z, eitherBound);
// Because the rectangle exceeds 180 degrees, it is safe to compute the horizontally
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b294052d/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWorld.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWorld.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWorld.java
index 17352b9..ebe11db 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWorld.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWorld.java
@@ -67,6 +67,11 @@ class GeoWorld extends GeoBaseBBox {
}
@Override
+ public boolean intersects(final GeoShape geoShape) {
+ return false;
+ }
+
+ @Override
public void getBounds(Bounds bounds) {
super.getBounds(bounds);
// Unnecessary