endLine method

void endLine()

Terminate the current LineString.

Implementation

void endLine() {
  if (coordList == null) {
    return;
  }
  if (ignoreInvalidLines && coordList!._backingList.length < 2) {
    coordList = null;
    return;
  }
  List<Coordinate> rawPts = coordList!.toCoordinateArray();
  List<Coordinate> pts = rawPts;
  if (fixInvalidLines) pts = validCoordinateSequence(rawPts);

  coordList = null;
  LineString? line = null;
  try {
    line = geomFact.createLineString(pts);
  } catch (ex) {
    // exception is due to too few points in line.
    // only propagate if not ignoring short lines
    if (!ignoreInvalidLines) throw ex;
  }

  if (line != null) lines.add(line);
}