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

This commit is contained in:
Karl Wright 2017-08-26 05:06:54 -04:00
parent 287ab9dc40
commit 2b8cea09bb
2 changed files with 7 additions and 5 deletions

View File

@ -27,9 +27,10 @@ package org.apache.lucene.spatial3d.geom;
public interface GeoAreaShape extends GeoMembershipShape, GeoArea{ public interface GeoAreaShape extends GeoMembershipShape, GeoArea{
/** /**
* Assess whether a shape intersects with any of the edges this shape. * Assess whether a shape intersects with any of the edges of this shape.
* Note well that this method return false if the shape contains, is within * Note well that this method must return false if the shape contains or is disjoint
* or is disjoint with the given shape. * 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. * @param geoShape is the shape to assess for intersection with this shape's edges.
* *

View File

@ -86,9 +86,10 @@ class GeoDegeneratePoint extends GeoPoint implements GeoBBox, GeoCircle {
@Override @Override
public boolean intersects(GeoShape geoShape) { 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 @Override
public void getBounds(Bounds bounds) { public void getBounds(Bounds bounds) {
bounds.addPoint(this); bounds.addPoint(this);