diff --git a/modules/core/src/main/java/org/locationtech/jts/coverage/CoverageRingEdges.java b/modules/core/src/main/java/org/locationtech/jts/coverage/CoverageRingEdges.java
index a2b83ddf55..d368ec2e5a 100644
--- a/modules/core/src/main/java/org/locationtech/jts/coverage/CoverageRingEdges.java
+++ b/modules/core/src/main/java/org/locationtech/jts/coverage/CoverageRingEdges.java
@@ -42,6 +42,11 @@
* splitting edges at nodes, and then identifying unique edges.
* The unique edges are associated to their parent ring (in order),
* to allow reforming the coverage polygons.
+ *
+ * One ring in each polygonal geometry is marked as primary.
+ * Primary edges are always retained during coverage processing
+ * (such as simplification), to ensure the geometry does not disappear entirely.
+ * The primary ring is the shell of the largest polygon in the geometry.
*
* @author Martin Davis
*
@@ -109,6 +114,12 @@ private void build() {
}
}
+ /**
+ * Finds the index of the polygonal element with largest area.
+ *
+ * @param geom the polygonal geometry to scan
+ * @return the index of the polygonal element with largest area
+ */
private int findLargestPolygonIndex(Geometry geom) {
if (geom instanceof Polygon)
return 0;
@@ -125,7 +136,20 @@ private int findLargestPolygonIndex(Geometry geom) {
return indexLargest;
}
- private void addRingEdges(int index, LinearRing ring, boolean isPrimary, Set nodes, Set boundarySegs,
+ /**
+ * Adds the {@link CoverageEdge}s for a ring
+ * to the map of ring edges.
+ *
+ * @param index the index of the geometry in the coverage
+ * @param ring the ring to extract edges from
+ * @param isPrimary true if the ring is primary (must not be removed)
+ * @param nodes nodes in the coverage
+ * @param boundarySegs the coverage boundary segments
+ * @param uniqueEdgeMap map of unique edges
+ */
+ private void addRingEdges(int index, LinearRing ring, boolean isPrimary,
+ Set nodes,
+ Set boundarySegs,
HashMap uniqueEdgeMap) {
addBoundaryInnerNodes(ring, boundarySegs, nodes);
List ringEdges = extractRingEdges(index, ring, isPrimary, uniqueEdgeMap, nodes);
@@ -139,9 +163,9 @@ private void addRingEdges(int index, LinearRing ring, boolean isPrimary, Set boundarySegs, Set nodes) {
CoordinateSequence seq = ring.getCoordinateSequence();
@@ -159,12 +183,12 @@ private void addBoundaryInnerNodes(LinearRing ring, Set boundarySeg
/**
* Extracts the {@link CoverageEdge}s for a ring.
- * @param index
*
- * @param ring
- * @param isRetained true if the ring is retained (must not be removed)
- * @param uniqueEdgeMap
- * @param nodes
+ * @param index the index of the geometry in the coverage
+ * @param ring the ring to extract edges from
+ * @param isPrimary true if the ring is primary (must not be removed)
+ * @param uniqueEdgeMap map of unique edges
+ * @param nodes nodes in the coverage
* @return null if the ring has too few distinct vertices
*/
private List extractRingEdges(int index, LinearRing ring,
@@ -211,8 +235,8 @@ private List extractRingEdges(int index, LinearRing ring,
* @param ring ring to create edge for
* @param start start index of ring section; -1 indicates edge is entire ring
* @param end end index of ring section
- * @param index
- * @param isPrimary whether this ring is a primary ring
+ * @param index the index of the parent geometry in the coverage
+ * @param isPrimary true if the ring is primary (must not be removed)
* @param uniqueEdgeMap map of edges
* @return the CoverageEdge for the ring or portion of ring
*/