addLineString method

void addLineString(
  1. LineString line
)

Implementation

void addLineString(LineString line) {
  List<Coordinate> coord =
      CoordinateArrays.removeRepeatedPoints(line.getCoordinates());

  if (coord.length < 2) {
    _hasTooFewPoints = true;
    invalidPoint = coord[0];
    return;
  }

  // add the edge for the LineString
  // line edges do not have locations for their left and right sides
  Edge e = new Edge(coord, new Label.args2(argIndex, Location.INTERIOR));
  lineEdgeMap[line] = e;
  insertEdge(e);
  /**
   * Add the boundary points of the LineString, if any.
   * Even if the LineString is closed, add both points as if they were endpoints.
   * This allows for the case that the node already exists and is a boundary point.
   */
  assert(coord.length >= 2, "found LineString with single point");
  insertBoundaryPoint(argIndex, coord[0]);
  insertBoundaryPoint(argIndex, coord[coord.length - 1]);
}