Skip to content

Commit

Permalink
Minor OverlayLabeller refactoring and improvement
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Davis <mtnclimb@gmail.com>
  • Loading branch information
dr-jts committed Sep 4, 2020
1 parent 1f41dd9 commit feee233
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public OverlayLabeller(OverlayGraph graph, InputGeometry inputGeometry) {
*/
public void computeLabelling() {
Collection<OverlayEdge> nodes = graph.getNodeEdges();

labelAreaNodeEdges(nodes);
labelConnectedLinearEdges();

//TODO: is there a way to avoid scanning all edges in these steps?
/**
Expand All @@ -59,6 +61,7 @@ public void computeLabelling() {
* The edges can be labeled based on their parent ring role (shell or hole).
*/
labelCollapsedEdges();
labelConnectedLinearEdges();

labelDisconnectedEdges();
}
Expand All @@ -78,7 +81,6 @@ private void labelAreaNodeEdges(Collection<OverlayEdge> nodes) {
propagateAreaLocations(nodeEdge, 1);
}
}
labelConnectedLinearEdges();
}

/**
Expand All @@ -89,9 +91,14 @@ private void labelAreaNodeEdges(Collection<OverlayEdge> nodes) {
*
* @param geomIndex the geometry to propagate locations for
*/
public static void propagateAreaLocations(OverlayEdge nodeEdge, int geomIndex) {
public void propagateAreaLocations(OverlayEdge nodeEdge, int geomIndex) {
/**
* This handles dangling edges created by overlap limiting
* Only propagate for area geometries
*/
if (! inputGeometry.isArea(geomIndex)) return;
/**
* No need to propagate if node has only one edge.
* This handles dangling edges created by overlap limiting.
*/
if (nodeEdge.degree() == 1) return;

Expand Down Expand Up @@ -144,7 +151,7 @@ public static void propagateAreaLocations(OverlayEdge nodeEdge, int geomIndex) {
}

/**
* Finds a boundary edge for this geom, if one exists
* Finds a boundary edge for this geom, if one exists.
*
* @param nodeEdge an edge for this node
* @param geomIndex the parent geometry index
Expand Down Expand Up @@ -196,7 +203,6 @@ private void labelCollapsedEdges() {
labelCollapsedEdge(edge, 1);
}
}
labelConnectedLinearEdges();
}

private void labelCollapsedEdge(OverlayEdge edge, int geomIndex) {
Expand Down

0 comments on commit feee233

Please sign in to comment.