addRingSide method

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

Adds an offset curve for one side of a ring. The side and left and right topological location arguments are provided as if the ring is oriented CW. (If the ring is in the opposite orientation, this is detected and the left and right locations are interchanged and the side is flipped.)

@param coord the coordinates of the ring (must not contain repeated points) @param offsetDistance the positive distance at which to create the buffer @param side the side {@link Position} 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 addRingSide(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);
}