addIntersectionNode method
Adds an intersection node for a given point and segment to this segment string. If an intersection already exists for this exact location, the existing node will be returned.
@param intPt the location of the intersection @param segmentIndex the index of the segment containing the intersection @return the intersection node for the point
Implementation
SegmentNode addIntersectionNode(Coordinate intPt, int segmentIndex) {
int normalizedSegmentIndex = segmentIndex;
//Debug.println("edge intpt: " + intPt + " dist: " + dist);
// normalize the intersection point location
int nextSegIndex = normalizedSegmentIndex + 1;
if (nextSegIndex < pts.length) {
Coordinate nextPt = pts[nextSegIndex];
//Debug.println("next pt: " + nextPt);
// Normalize segment index if intPt falls on vertex
// The check for point equality is 2D only - Z values are ignored
if (intPt.equals2D(nextPt)) {
//Debug.println("normalized distance");
normalizedSegmentIndex = nextSegIndex;
}
}
/**
* Add the intersection point to edge intersection list.
*/
SegmentNode ei = nodeList.add(intPt, normalizedSegmentIndex);
return ei;
}