createSplitEdgePts method

List<Coordinate> createSplitEdgePts(
  1. SegmentNode ei0,
  2. SegmentNode ei1
)

Extracts the points for a split edge running between two nodes. The extracted points should contain no duplicate points. There should always be at least two points extracted (which will be the given nodes).

@param ei0 the start node of the split edge @param ei1 the end node of the split edge @return the points for the split edge

Implementation

List<Coordinate> createSplitEdgePts(SegmentNode ei0, SegmentNode ei1) {
//Debug.println("\ncreateSplitEdge"); Debug.print(ei0); Debug.print(ei1);
  int npts = ei1.segmentIndex - ei0.segmentIndex + 2;

  // if only two points in split edge they must be the node points
  if (npts == 2)
    return [
      new Coordinate.fromCoordinate(ei0.coord),
      new Coordinate.fromCoordinate(ei1.coord)
    ];

  Coordinate lastSegStartPt = edge.getCoordinate(ei1.segmentIndex);
  /**
   * If the last intersection point is not equal to the its segment start pt,
   * add it to the points list as well.
   * This check is needed because the distance metric is not totally reliable!
   *
   * Also ensure that the created edge always has at least 2 points.
   *
   * The check for point equality is 2D only - Z values are ignored
   */
  bool useIntPt1 = ei1.isInterior() || !ei1.coord.equals2D(lastSegStartPt);
  if (!useIntPt1) {
    npts--;
  }

  List<Coordinate> pts = []; //..length = (npts);
  // int ipt = 0;
  pts.add(new Coordinate.fromCoordinate(ei0.coord));
  // pts[ipt++] = new Coordinate.fromCoordinate(ei0.coord);
  for (int i = ei0.segmentIndex + 1; i <= ei1.segmentIndex; i++) {
    pts.add(edge.getCoordinate(i));
    // pts[ipt++] = edge.getCoordinate(i);
  }
  if (useIntPt1) pts.add(new Coordinate.fromCoordinate(ei1.coord));
  // if (useIntPt1) pts[ipt] = new Coordinate.fromCoordinate(ei1.coord);
  return pts;
}