isErodedCompletely static method
Tests whether a ring buffer is eroded completely (is empty) based on simple heuristics.
The ringCoord is assumed to contain no repeated points. It may be degenerate (i.e. contain only 1, 2, or 3 points). In this case it has no area, and hence has a minimum diameter of 0.
@param ringCoord @param offsetDistance @return
Implementation
static bool isErodedCompletely(LinearRing ring, double bufferDistance)
{
List<Coordinate> ringCoord = ring.getCoordinates();
// degenerate ring has no area
if (ringCoord.length < 4)
return bufferDistance < 0;
// important test to eliminate inverted triangle bug
// also optimizes erosion test for triangles
if (ringCoord.length == 4)
return isTriangleErodedCompletely(ringCoord, bufferDistance);
// if envelope is narrower than twice the buffer distance, ring is eroded
Envelope env = ring.getEnvelopeInternal();
double envMinDimension = math.min(env.getHeight(), env.getWidth());
if (bufferDistance < 0.0
&& 2 * bufferDistance.abs() > envMinDimension)
return true;
return false;
}