flatten method

LineSegment flatten(
  1. int start,
  2. int end
)

Flattens a section of the line between indexes start and end, replacing them with a line between the endpoints. The input and output indexes are updated to reflect this.

@param start the start index of the flattened section @param end the end index of the flattened section @return the new segment created /

Implementation

LineSegment flatten(int start, int end) {
  // make a new segment for the simplified geometry
  Coordinate p0 = linePts[start];
  Coordinate p1 = linePts[end];
  LineSegment newSeg = LineSegment.fromCoordinates(p0, p1);
  // update the indexes
  remove(line, start, end);
  outputIndex.addSegment(newSeg);
  return newSeg;
}