addPolygonRing method

void addPolygonRing(
  1. List<Coordinate> coord,
  2. double offsetDistance,
  3. int side,
  4. int cwLeftLoc,
  5. int cwRightLoc,
)

Adds an offset curve for a polygon ring. The side and left and right topological location arguments assume that the ring is oriented CW. If the ring is in the opposite orientation, the left and right locations must be interchanged and the side flipped.

@param coord the coordinates of the ring (must not contain repeated points) @param offsetDistance the distance at which to create the buffer @param side the side of the ring on which to construct the buffer line @param cwLeftLoc the location on the L side of the ring (if it is CW) @param cwRightLoc the location on the R side of the ring (if it is CW)

Implementation

void addPolygonRing(List<Coordinate> coord, double offsetDistance, int side,
    int cwLeftLoc, int cwRightLoc) {
  // don't bother adding ring if it is "flat" and will disappear in the output
  if (offsetDistance == 0.0 && coord.length < LinearRing.MINIMUM_VALID_SIZE)
    return;

  int leftLoc = cwLeftLoc;
  int rightLoc = cwRightLoc;
  if (coord.length >= LinearRing.MINIMUM_VALID_SIZE &&
      Orientation.isCCW(coord)) {
    leftLoc = cwRightLoc;
    rightLoc = cwLeftLoc;
    side = Position.opposite(side);
  }
  List<Coordinate>? curve =
      curveBuilder.getRingCurve(coord, side, offsetDistance);
  addCurve(curve, leftLoc, rightLoc);
}