addPolygonRing method

void addPolygonRing(
  1. LinearRing lr,
  2. int cwLeft,
  3. int cwRight
)

Adds a polygon ring to the graph. Empty rings are ignored.

The left and right topological location arguments assume that the ring is oriented CW. If the ring is in the opposite orientation, the left and right locations must be interchanged.

Implementation

void addPolygonRing(LinearRing lr, int cwLeft, int cwRight) {
  // don't bother adding empty holes
  if (lr.isEmpty()) return;

  List<Coordinate> coord =
      CoordinateArrays.removeRepeatedPoints(lr.getCoordinates());

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

  int left = cwLeft;
  int right = cwRight;
  if (Orientation.isCCW(coord)) {
    left = cwRight;
    right = cwLeft;
  }
  Edge e = Edge(coord, Label.args4(argIndex, Location.BOUNDARY, left, right));
  lineEdgeMap[lr] = e;

  insertEdge(e);
  // insert the endpoint as a node, to mark that it is on the boundary
  insertPoint(argIndex, coord[0], Location.BOUNDARY);
}