addIntersection method

void addIntersection(
  1. LineIntersector li,
  2. int segmentIndex,
  3. int geomIndex,
  4. int intIndex,
)

Add an EdgeIntersection for intersection intIndex. An intersection that falls exactly on a vertex of the edge is normalized to use the higher of the two possible segmentIndexes

Implementation

void addIntersection(
    LineIntersector li, int segmentIndex, int geomIndex, int intIndex) {
  Coordinate intPt =
      new Coordinate.fromCoordinate(li.getIntersection(intIndex));
  int normalizedSegmentIndex = segmentIndex;
  double dist = li.getEdgeDistance(geomIndex, intIndex);
//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;
      dist = 0.0;
    }
  }
  /**
   * Add the intersection point to edge intersection list.
   */
  EdgeIntersection ei = eiList.add(intPt, normalizedSegmentIndex, dist);
//ei.print(System.out);
}