| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
package org.locationtech.jts.operation.overlay; |
| 15 |
|
| 16 |
import java.util.ArrayList; |
| 17 |
import java.util.List; |
| 18 |
|
| 19 |
import org.locationtech.jts.geom.GeometryFactory; |
| 20 |
import org.locationtech.jts.geomgraph.DirectedEdge; |
| 21 |
import org.locationtech.jts.geomgraph.DirectedEdgeStar; |
| 22 |
import org.locationtech.jts.geomgraph.EdgeRing; |
| 23 |
import org.locationtech.jts.geomgraph.Node; |
| 24 |
|
| 25 |
/** |
| 26 |
* A ring of {@link DirectedEdge}s which may contain nodes of degree > 2. |
| 27 |
* A <tt>MaximalEdgeRing</tt> may represent two different spatial entities: |
| 28 |
* <ul> |
| 29 |
* <li>a single polygon possibly containing inversions (if the ring is oriented CW) |
| 30 |
* <li>a single hole possibly containing exversions (if the ring is oriented CCW) |
| 31 |
* </ul> |
| 32 |
* If the MaximalEdgeRing represents a polygon, |
| 33 |
* the interior of the polygon is strongly connected. |
| 34 |
* <p> |
| 35 |
* These are the form of rings used to define polygons under some spatial data models. |
| 36 |
* However, under the OGC SFS model, {@link MinimalEdgeRing}s are required. |
| 37 |
* A MaximalEdgeRing can be converted to a list of MinimalEdgeRings using the |
| 38 |
* {@link #buildMinimalRings() } method. |
| 39 |
* |
| 40 |
* @version 1.7 |
| 41 |
* @see org.locationtech.jts.operation.overlay.MinimalEdgeRing |
| 42 |
*/ |
| 43 |
public class MaximalEdgeRing |
| 44 |
extends EdgeRing |
| 45 |
{ |
| 46 |
|
| 47 |
public MaximalEdgeRing(DirectedEdge start, GeometryFactory geometryFactory) { |
| 48 |
super(start, geometryFactory); |
| 49 |
} |
| 50 |
|
| 51 |
public DirectedEdge getNext(DirectedEdge de) |
| 52 |
{ |
| 53 |
return de.getNext(); |
| 54 |
} |
| 55 |
public void setEdgeRing(DirectedEdge de, EdgeRing er) |
| 56 |
{ |
| 57 |
de.setEdgeRing(er); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* For all nodes in this EdgeRing, |
| 62 |
* link the DirectedEdges at the node to form minimalEdgeRings |
| 63 |
*/ |
| 64 |
public void linkDirectedEdgesForMinimalEdgeRings() |
| 65 |
{ |
| 66 |
DirectedEdge de = startDe; |
| 67 |
do { |
| 68 |
Node node = de.getNode(); |
| 69 |
((DirectedEdgeStar) node.getEdges()).linkMinimalDirectedEdges(this); |
| 70 |
de = de.getNext(); |
| 71 |
} while (de != startDe); |
| 72 |
} |
| 73 |
|
| 74 |
public List buildMinimalRings() |
| 75 |
{ |
| 76 |
List minEdgeRings = new ArrayList(); |
| 77 |
DirectedEdge de = startDe; |
| 78 |
do { |
| 79 |
if (de.getMinEdgeRing() == null) { |
| 80 |
EdgeRing minEr = new MinimalEdgeRing(de, geometryFactory); |
| 81 |
minEdgeRings.add(minEr); |
| 82 |
} |
| 83 |
de = de.getNext(); |
| 84 |
} while (de != startDe); |
| 85 |
return minEdgeRings; |
| 86 |
} |
| 87 |
|
| 88 |
} |
| 89 |
|