createEdgeEndForPrev method

void createEdgeEndForPrev(
  1. Edge edge,
  2. List l,
  3. EdgeIntersection eiCurr,
  4. EdgeIntersection? eiPrev,
)

Create a EdgeStub for the edge before the intersection eiCurr. The previous intersection is provided in case it is the endpoint for the stub edge. Otherwise, the previous point from the parent edge will be the endpoint.
eiCurr will always be an EdgeIntersection, but eiPrev may be null.

Implementation

void createEdgeEndForPrev(
    Edge edge, List l, EdgeIntersection eiCurr, EdgeIntersection? eiPrev) {
  int iPrev = eiCurr.segmentIndex;
  if (eiCurr.dist == 0.0) {
    // if at the start of the edge there is no previous edge
    if (iPrev == 0) return;
    iPrev--;
  }
  Coordinate pPrev = edge.getCoordinateWithIndex(iPrev);
  // if prev intersection is past the previous vertex, use it instead
  if (eiPrev != null && eiPrev.segmentIndex >= iPrev) pPrev = eiPrev.coord;

  Label label = new Label.fromLabel(edge.getLabel()!);
  // since edgeStub is oriented opposite to it's parent edge, have to flip sides for edge label
  label.flip();
  EdgeEnd e = new EdgeEnd.withCoordsLabel(edge, eiCurr.coord, pPrev, label);
//e.print(System.out);  System.out.println();
  l.add(e);
}