LUCENE-8451: Interpret IllegalArgumentException result from convex polygon constructor as meaning a tiling failure.

This commit is contained in:
Karl Wright 2018-08-11 06:58:50 -04:00
parent e9addea087
commit f2c0005e9d
2 changed files with 22 additions and 15 deletions

View File

@ -1443,23 +1443,30 @@ public class GeoPolygonFactory {
}
// Now, construct the polygon
if (testPoint != null && holes != null && holes.size() > 0) {
// No holes, for test
final GeoPolygon testPolygon = new GeoConvexPolygon(planetModel, points, null, internalEdges, returnIsInternal);
if (testPolygon.isWithin(testPoint)) {
return null;
// Failures in construction mean we have a polygon that is too large (>180 degrees)
try {
if (testPoint != null && holes != null && holes.size() > 0) {
// No holes, for test
final GeoPolygon testPolygon = new GeoConvexPolygon(planetModel, points, null, internalEdges, returnIsInternal);
if (testPolygon.isWithin(testPoint)) {
return null;
}
}
final GeoPolygon realPolygon = new GeoConvexPolygon(planetModel, points, holes, internalEdges, returnIsInternal);
if (testPoint != null && (holes == null || holes.size() == 0)) {
if (realPolygon.isWithin(testPoint)) {
return null;
}
}
rval.addShape(realPolygon);
return true;
} catch (IllegalArgumentException e) {
throw new TileException(e.getMessage());
}
final GeoPolygon realPolygon = new GeoConvexPolygon(planetModel, points, holes, internalEdges, returnIsInternal);
if (testPoint != null && (holes == null || holes.size() == 0)) {
if (realPolygon.isWithin(testPoint)) {
return null;
}
}
rval.addShape(realPolygon);
return true;
}
/** Check if a point is within a set of edges.

View File

@ -1890,7 +1890,7 @@ shape:
}
@Test
@AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-8451")
//@AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-8451")
public void testLUCENE8451() {
//POLYGON((-2.5185339401969213 -24.093993739745027,0.0 8.828539494442529E-27,5.495998489568957E-11 -8.321407453133E-11,2.7174659198424288E-11 1.0260761462208114E-10,88.32137548549387 16.934529875343244,-87.97237709688223 39.919704493657484,-88.0876897472551 34.91204903885665,-2.5185339401969213 -24.093993739745027))
final List<GeoPoint> points = new ArrayList<>();