Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-7941: Broaden the contract for intersects() method, and implement the broadened contract in GeoDegeneratePoint.

Karl Wright2b8cea09bb38
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
index b00ffca2321..d977901266b 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoAreaShape.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoAreaShape.java
@@ -27,9 +27,10 @@ package org.apache.lucene.spatial3d.geom;
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.
+ * Assess whether a shape intersects with any of the edges of this shape.
+ * Note well that this method must return false if the shape contains or is disjoint
+ * with the given shape. It is permissible to return true if the shape is within the
+ * specified shape, if it is difficult to compute intersection with edges.
*
* @param geoShape is the shape to assess for intersection with this shape's edges.
*
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 8a96fdf10f3..b6c54fa0572 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
@@ -86,9 +86,10 @@ class GeoDegeneratePoint extends GeoPoint implements GeoBBox, GeoCircle {
@Override
public boolean intersects(GeoShape geoShape) {
- return false;
+ // We have no way of computing this properly, so return isWithin(), as we are allowed by contract.
+ return geoShape.isWithin(this);
}
-
+
@Override
public void getBounds(Bounds bounds) {
bounds.addPoint(this);