isErodedCompletely method

bool isErodedCompletely(
  1. LinearRing ring,
  2. double bufferDistance
)

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

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;
  /**
   * The following is a heuristic test to determine whether an
   * inside buffer will be eroded completely.
   * It is based on the fact that the minimum diameter of the ring pointset
   * provides an upper bound on the buffer distance which would erode the
   * ring.
   * If the buffer distance is less than the minimum diameter, the ring
   * may still be eroded, but this will be determined by
   * a full topological computation.
   *
   */
//System.out.println(ring);
/* MD  7 Feb 2005 - there's an unknown bug in the MD code, so disable this for now
  MinimumDiameter md = new MinimumDiameter(ring);
  minDiam = md.getLength();
  //System.out.println(md.getDiameter());
  return minDiam < 2 * Math.abs(bufferDistance);
  */
}