checkNoSelfIntersectingRing method
Check that a ring does not self-intersect, except at its endpoints. Algorithm is to count the number of times each node along edge occurs. If any occur more than once, that must be a self-intersection.
Implementation
void checkNoSelfIntersectingRing(EdgeIntersectionList eiList) {
Set nodeSet = new SplayTreeSet();
bool isFirst = true;
for (Iterator i = eiList.iterator(); i.moveNext();) {
EdgeIntersection ei = i.current as EdgeIntersection;
if (isFirst) {
isFirst = false;
continue;
}
if (nodeSet.contains(ei.coord)) {
validErr = new TopologyValidationError.withCoordinate(
TopologyValidationError.RING_SELF_INTERSECTION, ei.coord);
return;
} else {
nodeSet.add(ei.coord);
}
}
}