mirror of https://github.com/apache/lucene.git
LUCENE-8220: Fix yet another case where we cannot tile.
This commit is contained in:
parent
4bb02d8689
commit
26ba705a4f
|
@ -175,20 +175,20 @@ public class GeoPolygonFactory {
|
||||||
holes = null;
|
holes = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, exercise a sanity filter on the provided pointList, and remove identical points, linear points, and backtracks
|
if (description.points.size() <= SMALL_POLYGON_CUTOFF_EDGES) {
|
||||||
//System.err.println(" filtering "+pointList.size()+" points...");
|
// First, exercise a sanity filter on the provided pointList, and remove identical points, linear points, and backtracks
|
||||||
//final long startTime = System.currentTimeMillis();
|
//System.err.println(" filtering "+pointList.size()+" points...");
|
||||||
final List<GeoPoint> firstFilteredPointList = filterPoints(description.points);
|
//final long startTime = System.currentTimeMillis();
|
||||||
if (firstFilteredPointList == null) {
|
final List<GeoPoint> firstFilteredPointList = filterPoints(description.points);
|
||||||
return null;
|
if (firstFilteredPointList == null) {
|
||||||
}
|
return null;
|
||||||
final List<GeoPoint> filteredPointList = filterEdges(firstFilteredPointList, leniencyValue);
|
}
|
||||||
//System.err.println(" ...done in "+(System.currentTimeMillis()-startTime)+"ms ("+((filteredPointList==null)?"degenerate":(filteredPointList.size()+" points"))+")");
|
final List<GeoPoint> filteredPointList = filterEdges(firstFilteredPointList, leniencyValue);
|
||||||
if (filteredPointList == null) {
|
//System.err.println(" ...done in "+(System.currentTimeMillis()-startTime)+"ms ("+((filteredPointList==null)?"degenerate":(filteredPointList.size()+" points"))+")");
|
||||||
return null;
|
if (filteredPointList == 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,25 +1182,27 @@ 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);
|
if (testPolygon.isWithin(testPoint)) {
|
||||||
if (testPolygon.isWithin(testPoint)) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
final GeoPolygon realPolygon = new GeoConcavePolygon(planetModel, points, holes, internalEdges, isInternal);
|
||||||
final GeoPolygon realPolygon = new GeoConcavePolygon(planetModel, points, holes, internalEdges, isInternal);
|
if (testPoint != null && (holes == null || holes.size() == 0)) {
|
||||||
if (testPoint != null && (holes == null || holes.size() == 0)) {
|
if (realPolygon.isWithin(testPoint)) {
|
||||||
if (realPolygon.isWithin(testPoint)) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rval.addShape(realPolygon);
|
||||||
|
return true;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new TileException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
rval.addShape(realPolygon);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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.
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue