| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
package org.locationtech.jts.operation.linemerge; |
| 14 |
|
| 15 |
import org.locationtech.jts.geom.Coordinate; |
| 16 |
import org.locationtech.jts.planargraph.DirectedEdge; |
| 17 |
import org.locationtech.jts.planargraph.Node; |
| 18 |
import org.locationtech.jts.util.Assert; |
| 19 |
|
| 20 |
/** |
| 21 |
* A {@link org.locationtech.jts.planargraph.DirectedEdge} of a |
| 22 |
* {@link LineMergeGraph}. |
| 23 |
* |
| 24 |
* @version 1.7 |
| 25 |
*/ |
| 26 |
public class LineMergeDirectedEdge extends DirectedEdge { |
| 27 |
/** |
| 28 |
* Constructs a LineMergeDirectedEdge connecting the <code>from</code> node to the |
| 29 |
* <code>to</code> node. |
| 30 |
* |
| 31 |
* @param directionPt |
| 32 |
* specifies this DirectedEdge's direction (given by an imaginary |
| 33 |
* line from the <code>from</code> node to <code>directionPt</code>) |
| 34 |
* @param edgeDirection |
| 35 |
* whether this DirectedEdge's direction is the same as or |
| 36 |
* opposite to that of the parent Edge (if any) |
| 37 |
*/ |
| 38 |
public LineMergeDirectedEdge(Node from, Node to, Coordinate directionPt, |
| 39 |
boolean edgeDirection) { |
| 40 |
super(from, to, directionPt, edgeDirection); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Returns the directed edge that starts at this directed edge's end point, or null |
| 45 |
* if there are zero or multiple directed edges starting there. |
| 46 |
* @return the directed edge |
| 47 |
*/ |
| 48 |
public LineMergeDirectedEdge getNext() { |
| 49 |
if (getToNode().getDegree() != 2) { |
| 50 |
return null; |
| 51 |
} |
| 52 |
if (getToNode().getOutEdges().getEdges().get(0) == getSym()) { |
| 53 |
return (LineMergeDirectedEdge) getToNode().getOutEdges().getEdges().get(1); |
| 54 |
} |
| 55 |
Assert.isTrue(getToNode().getOutEdges().getEdges().get(1) == getSym()); |
| 56 |
|
| 57 |
return (LineMergeDirectedEdge) getToNode().getOutEdges().getEdges().get(0); |
| 58 |
} |
| 59 |
} |
| 60 |
|