Template:Clean Options

From XMS Wiki
Jump to navigationJump to search
The Clean Options dialog

The Clean Options dialog can be accessed by clicking the Clean 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 – Selecting this option will not immediately clean objects in the coverage. After exiting the dialog, with this option on, a point or node can be selected then snapped to another selected point or node.


The Cleaning Algorithm

The cleaning algorithm performs several operations, in order. This process involves maintaining "sorted" lists of locations (nodes and vertices) and arc segments. Disjoint points that are not part of an arc are not considered when cleaning.

Locations are sorted from left-to-right by their X-coordinates, with ties broken by sorting from bottom-to-top by their Y-coordinates. Segments are sorted by first sorting the locations of the segment, then sorting the segments by their "first" points, then finally breaking ties by their "last" points.

When cleaning selected features, only the ones that are selected are considered. Unselected features will not snap to anything, and nothing will snap to them. From the cleaner's perspective, it is as if they do not exist.

The cleaner distinguishes between "snapping", which moves features around and creates duplicate locations, and "merging", which combines duplicate locations into a single node. Merging happens at the end, after everything is finished moving.

  • Location snapping :
This is always done when cleaning is enabled. The process is to select the first location, then snap all other locations within distance to it before proceeding to the next location.
  • Arc snapping :
This is only done if the cleaning mode is set to "All". 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 vertex at the snapping point, and the two new segments will be added to the list of segments to consider. The node and vertex will be merged in a later step.
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.
  • Arc intersection :
This is only done if the cleaning mode is set to "All". This step inserts nodes wherever two arc segments intersect. 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. Since the two segments do not actually cross, intersection will not do anything with them.
  • Merging :
This step finds all nodes and vertices which share a location and merges them into a single node. If the resulting node was originally a vertex, and can still be a vertex, the cleaner will convert it back afterward.
  • Deduplication :
This step is always performed when cleaning 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.
  • Remove dangling arcs :
This step is performed after all other steps are finished.

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.

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