computeOffsetCurve method

void computeOffsetCurve(
  1. List<Coordinate> inputPts,
  2. bool isRightSide,
  3. OffsetSegmentGenerator segGen
)

Implementation

void computeOffsetCurve(List<Coordinate> inputPts, bool isRightSide,
    OffsetSegmentGenerator segGen) {
  double distTol = simplifyTolerance(distance);

  if (isRightSide) {
    //---------- compute points for right side of line
    // Simplify the appropriate side of the line before generating
    List<Coordinate> simp2 =
        BufferInputLineSimplifier.simplify(inputPts, -distTol);
    // MD - used for testing only (to eliminate simplification)
    //    List<Coordinate> simp2 = inputPts;
    int n2 = simp2.length - 1;

    // since we are traversing line in opposite order, offset position is still LEFT
    segGen.initSideSegments(simp2[n2], simp2[n2 - 1], Position.LEFT);
    segGen.addFirstSegment();
    for (int i = n2 - 2; i >= 0; i--) {
      segGen.addNextSegment(simp2[i], true);
    }
  } else {
    //--------- compute points for left side of line
    // Simplify the appropriate side of the line before generating
    List<Coordinate> simp1 =
        BufferInputLineSimplifier.simplify(inputPts, distTol);
    // MD - used for testing only (to eliminate simplification)
//      List<Coordinate> simp1 = inputPts;

    int n1 = simp1.length - 1;
    segGen.initSideSegments(simp1[0], simp1[1], Position.LEFT);
    segGen.addFirstSegment();
    for (int i = 2; i <= n1; i++) {
      segGen.addNextSegment(simp1[i], true);
    }
  }
  segGen.addLastSegment();
}