computeLabelOn method

void computeLabelOn(
  1. int geomIndex,
  2. BoundaryNodeRule boundaryNodeRule
)

Compute the overall ON location for the list of EdgeStubs. (This is essentially equivalent to computing the self-overlay of a single Geometry) edgeStubs can be either on the boundary (e.g. Polygon edge) OR in the interior (e.g. segment of a LineString) of their parent Geometry. In addition, GeometryCollections use a {@link BoundaryNodeRule} to determine whether a segment is on the boundary or not. Finally, in GeometryCollections it can occur that an edge is both on the boundary and in the interior (e.g. a LineString segment lying on top of a Polygon edge.) In this case the Boundary is given precedence.
These observations result in the following rules for computing the ON location:

  • if there are an odd number of Bdy edges, the attribute is Bdy
  • if there are an even number >= 2 of Bdy edges, the attribute is Int
  • if there are any Int edges, the attribute is Int
  • otherwise, the attribute is NULL.

Implementation

void computeLabelOn(int geomIndex, BoundaryNodeRule boundaryNodeRule) {
  // compute the ON location value
  int boundaryCount = 0;
  bool foundInterior = false;

  for (Iterator it = iterator(); it.moveNext();) {
    EdgeEnd e = it.current as EdgeEnd;
    int loc = e.getLabel()!.getLocation(geomIndex);
    if (loc == Location.BOUNDARY) boundaryCount++;
    if (loc == Location.INTERIOR) foundInterior = true;
  }
  int loc = Location.NONE;
  if (foundInterior) loc = Location.INTERIOR;
  if (boundaryCount > 0) {
    loc = GeometryGraph.determineBoundary(boundaryNodeRule, boundaryCount);
  }
  label!.setLocationWithIndex(geomIndex, loc);
}