LUCENE-8239: Handle degenerate vector case on linear edge evaluation.

This commit is contained in:
Karl Wright 2018-04-05 13:56:21 -04:00
parent 27f4772678
commit 74c2b798eb
2 changed files with 8 additions and 4 deletions

View File

@ -195,7 +195,7 @@ class GeoComplexPolygon extends GeoBasePolygon {
}
// If we're right on top of any of the test planes, we navigate solely on that plane.
if (testPointFixedYPlane.evaluateIsZero(x, y, z)) {
if (testPointFixedYAbovePlane != null && testPointFixedYBelowPlane != null && testPointFixedYPlane.evaluateIsZero(x, y, z)) {
// Use the XZ plane exclusively.
final CountingEdgeIterator crossingEdgeIterator = createLinearCrossingEdgeIterator(testPointFixedYPlane, testPointFixedYAbovePlane, testPointFixedYBelowPlane, x, y, z);
// Traverse our way from the test point to the check point. Use the y tree because that's fixed.
@ -204,7 +204,7 @@ class GeoComplexPolygon extends GeoBasePolygon {
return true;
}
return ((crossingEdgeIterator.getCrossingCount() & 1) == 0)?testPointInSet:!testPointInSet;
} else if (testPointFixedXPlane.evaluateIsZero(x, y, z)) {
} else if (testPointFixedXAbovePlane != null && testPointFixedXBelowPlane != null && testPointFixedXPlane.evaluateIsZero(x, y, z)) {
// Use the YZ plane exclusively.
final CountingEdgeIterator crossingEdgeIterator = createLinearCrossingEdgeIterator(testPointFixedXPlane, testPointFixedXAbovePlane, testPointFixedXBelowPlane, x, y, z);
// Traverse our way from the test point to the check point. Use the x tree because that's fixed.
@ -213,7 +213,7 @@ class GeoComplexPolygon extends GeoBasePolygon {
return true;
}
return ((crossingEdgeIterator.getCrossingCount() & 1) == 0)?testPointInSet:!testPointInSet;
} else if (testPointFixedZPlane.evaluateIsZero(x, y, z)) {
} else if (testPointFixedZAbovePlane != null && testPointFixedZBelowPlane != null && testPointFixedZPlane.evaluateIsZero(x, y, z)) {
final CountingEdgeIterator crossingEdgeIterator = createLinearCrossingEdgeIterator(testPointFixedZPlane, testPointFixedZAbovePlane, testPointFixedZBelowPlane, x, y, z);
// Traverse our way from the test point to the check point. Use the z tree because that's fixed.
if (!zTree.traverse(crossingEdgeIterator, testPoint.z)) {
@ -221,6 +221,8 @@ class GeoComplexPolygon extends GeoBasePolygon {
return true;
}
return ((crossingEdgeIterator.getCrossingCount() & 1) == 0)?testPointInSet:!testPointInSet;
} else if (testPointFixedYPlane.evaluateIsZero(x, y, z) || testPointFixedXPlane.evaluateIsZero(x, y, z) || testPointFixedZPlane.evaluateIsZero(x, y, z)) {
throw new IllegalArgumentException("Can't compute isWithin for specified point");
} else {
// This is the expensive part!!
@ -903,6 +905,9 @@ class GeoComplexPolygon extends GeoBasePolygon {
this.plane = plane;
this.abovePlane = abovePlane;
this.belowPlane = belowPlane;
if (plane.isNumericallyIdentical(testPoint)) {
throw new IllegalArgumentException("Plane vector identical to testpoint vector");
}
// It doesn't matter which 1/2 of the world we choose, but we must choose only one.
this.bound = new SidedPlane(plane, testPoint);
this.thePointX = thePointX;

View File

@ -1450,7 +1450,6 @@ shape:
assertTrue(polygon.isWithin(point1) == largePolygon.isWithin(point1));
}
@Ignore
@Test
public void testComplexPolygonDegeneratedVector() {
List<GeoPoint> points = new ArrayList<>();