LUCENE-8220: Fix yet another case where we cannot tile.

This commit is contained in:
Karl Wright 2018-03-26 06:20:34 -04:00
parent 4bb02d8689
commit 26ba705a4f
2 changed files with 60 additions and 30 deletions

View File

@ -175,6 +175,7 @@ public class GeoPolygonFactory {
holes = null; holes = null;
} }
if (description.points.size() <= SMALL_POLYGON_CUTOFF_EDGES) {
// First, exercise a sanity filter on the provided pointList, and remove identical points, linear points, and backtracks // First, exercise a sanity filter on the provided pointList, and remove identical points, linear points, and backtracks
//System.err.println(" filtering "+pointList.size()+" points..."); //System.err.println(" filtering "+pointList.size()+" points...");
//final long startTime = System.currentTimeMillis(); //final long startTime = System.currentTimeMillis();
@ -188,7 +189,6 @@ public class GeoPolygonFactory {
return null; return null;
} }
if (filteredPointList.size() <= SMALL_POLYGON_CUTOFF_EDGES) {
try { try {
//First approximation to find a point //First approximation to find a point
final GeoPoint centerOfMass = getCenterOfMass(planetModel, filteredPointList); final GeoPoint centerOfMass = getCenterOfMass(planetModel, filteredPointList);
@ -1144,7 +1144,7 @@ public class GeoPolygonFactory {
final MutableBoolean seenConcave, final MutableBoolean seenConcave,
final EdgeBuffer edgeBuffer, final EdgeBuffer edgeBuffer,
final List<GeoPolygon> holes, final List<GeoPolygon> holes,
final GeoPoint testPoint) { final GeoPoint testPoint) throws TileException {
if (edgeBuffer.size() == 0) { if (edgeBuffer.size() == 0) {
return true; return true;
@ -1182,8 +1182,7 @@ public class GeoPolygonFactory {
edge = edgeBuffer.getNext(edge); edge = edgeBuffer.getNext(edge);
} }
// Since we attempt to prevent the addition of any edge that shows up as colinear, and we filter out colinear edge parts try {
// beforehand, it isn't possible to have a colinear edge at this point.
if (testPoint != null && holes != null && holes.size() > 0) { if (testPoint != null && holes != null && holes.size() > 0) {
// No holes, for test // No holes, for test
final GeoPolygon testPolygon = new GeoConcavePolygon(planetModel, points, null, internalEdges, isInternal); final GeoPolygon testPolygon = new GeoConcavePolygon(planetModel, points, null, internalEdges, isInternal);
@ -1201,6 +1200,9 @@ public class GeoPolygonFactory {
rval.addShape(realPolygon); rval.addShape(realPolygon);
return true; return true;
} catch (IllegalArgumentException e) {
throw new TileException(e.getMessage());
}
} }
/** Look for a convex polygon at the specified edge. If we find it, create one and adjust the edge buffer. /** Look for a convex polygon at the specified edge. If we find it, create one and adjust the edge buffer.

View File

@ -1176,4 +1176,32 @@ shape:
Collections.reverse(points); Collections.reverse(points);
polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points); polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
} }
@Test
public void testCoplanarityConvex2() throws Exception {
//POLYGON((-3.488658 50.45564,-3.4898987 50.455627,-3.489865 50.455585,-3.489833 50.45551,-3.489808 50.455433,-3.489806 50.455406,-3.4898643 50.45525,-3.4892037 50.455162,-3.4891756 50.455166,-3.4891088 50.455147,-3.4890108 50.455166,-3.4889853 50.455166,-3.48895 50.45516,-3.488912 50.455166,-3.4889014 50.455177,-3.488893 50.455185,-3.488927 50.45523,-3.4890666 50.455456,-3.48905 50.455467,-3.488658 50.45564))
List<GeoPoint> points = new ArrayList<>();
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.45564), Geo3DUtil.fromDegrees(-3.488658)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455627), Geo3DUtil.fromDegrees(-3.4898987)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455585), Geo3DUtil.fromDegrees(-3.489865)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.45551), Geo3DUtil.fromDegrees(-3.489833)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455433), Geo3DUtil.fromDegrees(-3.489808)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455406), Geo3DUtil.fromDegrees(-3.489806)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.45525), Geo3DUtil.fromDegrees(-3.4898643)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455162), Geo3DUtil.fromDegrees(-3.4892037)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455166), Geo3DUtil.fromDegrees(-3.4891756)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455147), Geo3DUtil.fromDegrees(-3.4891088)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455166), Geo3DUtil.fromDegrees(-3.4890108)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455166), Geo3DUtil.fromDegrees(-3.4889853)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.45516), Geo3DUtil.fromDegrees(-3.48895)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455166), Geo3DUtil.fromDegrees(-3.488912)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455177), Geo3DUtil.fromDegrees(-3.4889014)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455185), Geo3DUtil.fromDegrees( -3.488893)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.45523), Geo3DUtil.fromDegrees(-3.488927)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455456), Geo3DUtil.fromDegrees(-3.4890666)));
points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455467), Geo3DUtil.fromDegrees( -3.48905)));
GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
Collections.reverse(points);
polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
}
} }