hasNonEndpointIntersection method

bool hasNonEndpointIntersection(
  1. GeometryGraph graph
)

For all edges, check if there are any intersections which are NOT at an endpoint. The Geometry is not simple if there are intersections not at endpoints.

Implementation

bool hasNonEndpointIntersection(GeometryGraph graph) {
  for (Iterator i = graph.getEdgeIterator(); i.moveNext();) {
    Edge e = i.current as Edge;
    int maxSegmentIndex = e.getMaximumSegmentIndex();
    for (Iterator eiIt = e.getEdgeIntersectionList().iterator();
        eiIt.moveNext();) {
      EdgeIntersection ei = eiIt.current as EdgeIntersection;
      if (!ei.isEndPoint(maxSegmentIndex)) {
        nonSimpleLocation = ei.getCoordinate();
        return true;
      }
    }
  }
  return false;
}