Template:Clean Options: Difference between revisions

From XMS Wiki
Jump to navigationJump to search
Line 53: Line 53:


Note: The example images have grid lines displayed every 0.5 units. Unless otherwise noted, all examples use Mode=All, Features=All, and Distance=1. Any unspecified clean options are off.
Note: The example images have grid lines displayed every 0.5 units. Unless otherwise noted, all examples use Mode=All, Features=All, and Distance=1. Any unspecified clean options are off.
'''Example 1: point sorting'''
:In figure 1, Location 1 sorts before 2 because its Y-coordinate is lower, and it sorts before 3 and 4 because its X-coordinate is lower. Location 2 sorts before 3 and 4 because its X-coordinate is lower. Then 3 sorts before 4 because its Y-coordinate is lower. Location 4 is last because it has the highest X and Y coordinates.
[[ File:CleanFigure1.png | thumb | none | 300 px | Figure 1, Example 1]]


; Example 1 : Node 5 snaps to node 1, and node 6 snaps to arc 2.
; Example 1 : Node 5 snaps to node 1, and node 6 snaps to arc 2.

Revision as of 22:24, 11 March 2024

The Clean Options dialog

The Clean Options dialog can be accessed by clicking the Clean Mf6clean.svg macro or the Feature Objects | Clean... menu command.

The dialog has several options for cleaning feature objects on a map coverage.

  • Features – Determines which features will have clean operations applied to them.
    • All – Every feature in the coverage will be considered by the cleaner, regardless of whether the feature is selected or not.
    • Selected – Only features that are currently selected will be considered. Any unselected features will be ignored by the cleaner, as if they don't exist.
  • Snap distance – Indicates how close two features must be in order to snap them together. Features which are within Snap distance of each other can snap together, while those further than this distance cannot. Features are moved one at a time, so it is possible that snapping one feature will make another opportunity available, or make an existing opportunity no longer available. This is also a per-move limit. The current implementation of the cleaner allows features to move up to 5 times each, so a feature's total movement may be as far as 5 snapping distances.
  • Full clean – Enables or disables all of its sub-options at once. This is the typical way of cleaning a coverage, but the sub-options can be controlled individually if desired.
    • Snap points, nodes, and vertices together – Controls whether points, nodes and vertices will snap to each other.
    • Snap points, nodes, and vertices to arc segments – Controls whether points, nodes and vertices will snap to arc segments.
    • Intersect arc segments – Controls whether nodes will be inserted where arcs intersect.
  • Remove arcs less than ___ in length – Sets a length value which the clean tool will use to remove arcs that are less than the set value.
  • Snap selected points, nodes, and vertices – If this option is chosen, SMS will wait for the user to choose a snap target by clicking on any point, node, or vertex, or cancel the operation by clicking away from any valid target. Once a target is chosen, all currently selected points, nodes and vertices will be snapped to it. This is equivalent to clicking and dragging each of the selected points onto the snap target, which is a more typical workflow in SMS.


The Cleaning Algorithm

The cleaning algorithm applies several clean operations to the coverage in sequence. If snapping to segments is enabled, it is possible that cleaning the coverage once will create new cleaning opportunities, so the cleaner will apply multiple iterations and check for convergence.

The cleaning process involves maintaining "sorted" lists of locations (points, nodes and vertices) and arc segments.

  1. Sorting
Locations are sorted from left-to-right by their X-coordinates, with ties broken by sorting from bottom-to-top by their Y-coordinates (example 1).
Segments are sorted by comparing their endpoints using the same comparison as for locations. Then the "first" locations on each segment are compared, and the segment containing the earlier location is chosen first. In the event of a tie, the "second" location is used to break the tie (example 2).
  1. Steps
Note that when a location is moved, it is locked in place for the remainder of the iteration.
Vertex removal

This step is controlled by the *Snap points, nodes, and vertices together* checkbox. It always runs with the *Snap to points and nodes* and *Snap to vertices* steps. The process is to examine each segment on an arc looking for any segment that is shorter than the snap distance. If one is found, the vertex at the center of the sharpest bend is kept, and the other is removed. The first and last segments are considered last (example 3).

Snap to points and nodes
This step is controlled by the *Snap points, nodes, and vertices together* checkbox. It always runs with the *Vertex removal* and *Snap to vertices* steps. The process is to select the first point or node, then snap all other locations within distance to it before proceeding to the next location. This can remove some opportunities for snapping to locations by snapping a location away from where it otherwise might have gone (example 4). It can also create or remove opportunities for snapping to segments by moving segments toward or away from locations (example 5).
The locations of points and nodes are generally more significant than those of vertices. By only considering points and nodes as snap targets, this step ensures that the location of a vertex is never favored over that of a point or node (example 6).
Snap to vertices
This step is controlled by the *Snap points, nodes and vertices together* checkbox. It always runs with the *Vertex removal* and *Snap to points and nodes* steps. It is identical to the Snap to points and nodes step, except that vertices are now considered as snap targets (example 6).
Since the *Snap to points and nodes* step already snapped everything near points and nodes together, this step can only move vertices around.
Snap to segments
This step is controlled by the *Snap points, nodes, and vertices to arc segments* checkbox. The process is to select the first segment, then examine all other locations, in order, to find one that is within snapping distance. Once found, the nearby location will be snapped to the nearest location on the segment. The segment will also be split in two by inserting a node at the snapping point, and the two new segments will be added to the list of segments to consider (example 7).
Note that this step only snaps to interior locations on a segment. If it finds that the closest location on the segment is actually an endpoint, then the location being considered will be skipped, even though it is within snapping distance of the segment (example 8). Snapping to endpoints is only done by the *Snap to locations* step.
Arc intersection
This step is controlled by the *Intersect arc segments* checkbox. This step inserts nodes wherever two arc segments intersect (example 9). Intersection is done in an order similar to arc snapping, but since no movement happens, order is typically unimportant.
Intersection only considers locations where two arcs cross. An arc segment may also have an endpoint on another arc segment (example 10). Since the two segments do not actually cross, intersection will not do anything with them. To clean this case, segment snapping must be enabled.
Deduplication
This step is always performed when any cleaning option is enabled. It removes any arcs that are duplicates of each other. When removing a duplicate arc, it preferentially removes arcs which are not part of a polygon.
Vertex restoration
This step is always performed when any cleaning option is enabled. It looks for cases where a vertex became a node, and attempts to convert the node back to a vertex again. See example 11.
Remove dangling arcs
This step is performed after all other steps are finished. Unlike the other steps, it only runs once, at the very end. It scans the coverage for any arc that is shorter than the specified length, and deletes it. If the arc was the only one attached to a node, then the node will also be removed along with it (example 12).

Examples

Note: The example images have grid lines displayed every 0.5 units. Unless otherwise noted, all examples use Mode=All, Features=All, and Distance=1. Any unspecified clean options are off.

Example 1: point sorting

In figure 1, Location 1 sorts before 2 because its Y-coordinate is lower, and it sorts before 3 and 4 because its X-coordinate is lower. Location 2 sorts before 3 and 4 because its X-coordinate is lower. Then 3 sorts before 4 because its Y-coordinate is lower. Location 4 is last because it has the highest X and Y coordinates.
Figure 1, Example 1
Example 1
Node 5 snaps to node 1, and node 6 snaps to arc 2.
Example 1 start
Example 1 cleaned
Example 2
This example uses Mode=Locations. Node 5 snaps to node 1, but node 6 does not snap to arc 2 because Mode=Locations does not snap locations to arcs.
Example 2 start
Example 2 cleaned
Example 3
Node 5 snaps to node 1, then node 6 snaps to node 7. Next, node 6 snaps again to arc 2. Nodes 7 and 8 are within range of arc 2, but their snap target is an endpoint of a segment now, so the segment snapper skips them. Arc 4 has no intersection inserted because it does not intersect anything. The end of arc 3 happens to be on arc 4, as well as a vertex on arc 2, but the intersector only considers segments that actually cross.
Example 3 start
Example 3 cleaned
Example 4
This example uses Mode=Locations. Node 3 snaps to node 1, which makes it too far away to snap to node 5. Node 7 then snaps to node 5, making it too far away to snap to node 9. Nothing else snaps.
Example 4 start
Example 4 cleaned
Example 5
Note how, initially, node 4 is too far from arc 3 to snap to it. The cleaner first snaps node 5 to node 2, which reduces the distance between node 4 and arc 3, allowing node 4 to snap to arc 3 in the end.
Example 5 start
Example 5 cleaned
Example 6
This example has a single arc with several vertices. The cleaner snaps the vertices near the center of the hourglass together, producing two different arcs.
Example 6 start
Example 6 cleaned
Example 7
The nodes on arc 2 snap to the vertices on arc 1. This turns the vertices into nodes, and results in a duplicate arc. The cleaner discards the duplicate arc, then observes the nodes can be turned back into vertices, and does so.
Example 7 start
Example 7 cleaned
Example 8
This example uses Features=Selected. Arcs 1, 2, and 6 are selected. Nodes 12 and 9 are selected.
Node 12 snaps to arc 1, inserting a vertex in the process. Next it snaps to arc 2, where it remains. Arc 1 is never intersected with arc 10, because by this point there is no longer an intersection.
Node 8 does not snap to arc 6 because the node is not selected. Similarly, node 9 does not snap to arc 4 because the arc is not selected.
Example 8 start
Example 8 cleaned
Example 9
Previous examples mainly used nodes, but this one shows that vertices also snap. The vertex on arc 2 is snapped to the right vertical segment on arc 1. Additionally, arc 1 is self-intersecting, so the cleaner inserts a node where it intersects itself.
Example 9 start
Example 9 cleaned