User:Jcreer/Clean Options: Difference between revisions

From XMS Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 12: Line 12:
**''Distance'' – The maximum distance a location is allowed to move to snap to another feature. Note that features are snapped one at a time, which means it is possible for one step to move a feature to within snapping distance for another step, or to move it too far away.
**''Distance'' – The maximum distance a location is allowed to move to snap to another feature. Note that features are snapped one at a time, which means it is possible for one step to move a feature to within snapping distance for another step, or to move it too far away.
*''Remove short (dangling) arcs'' – Removes arcs that are below a provided length.
*''Remove short (dangling) arcs'' – Removes arcs that are below a provided length.
**
**''Up to length'' – Enter the length value for removing dangling arcs.
*''Snap selected nodes'' – Snaps all currently selected nodes to the next node you click after exiting the dialog. This option is unavailable if no nodes are selected, or if features other than nodes are selected (e.g. vertices, arcs, or disjoint points). This option can only be used by itself, since it is an interactive operation while the others are automated.
*''Snap selected nodes'' – Snaps all currently selected nodes to the next node clicked after exiting the dialog. This option is unavailable if no nodes are selected, or if features other than nodes are selected (e.g. vertices, arcs, or disjoint points). This option can only be used by itself, since it is an interactive operation while the others are automated.


===The cleaning algorithm===
===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.
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.

Revision as of 19:57, 6 February 2024

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.

  • Clean coverage – When turn on, this option enables cleaning of the coverage. Cleaning applies operations such as snapping locations to nearby locations and arcs, and inserting nodes where arcs intersect. The algorithm used is described in more detail below. This option has the following sub-options:
    • Mode dropdown
      • "Locations (nodes, vertices)" – Will only snap locations to nearby locations. Locations will not be snapped to nearby arcs, and no intersection nodes will be inserted.
      • "All (arcs, nodes, vertices)" – A superset of the "Locations" operation. In addition to snapping to locations, it will also snap to arcs and insert intersections.
    • All – Clean all features in the coverage.
    • Selected – Only clean selected ones. Selected features will not snap to nearby unselected features.
    • Distance – The maximum distance a location is allowed to move to snap to another feature. Note that features are snapped one at a time, which means it is possible for one step to move a feature to within snapping distance for another step, or to move it too far away.
  • Remove short (dangling) arcs – Removes arcs that are below a provided length.
    • Up to length – Enter the length value for removing dangling arcs.
  • Snap selected nodes – Snaps all currently selected nodes to the next node clicked after exiting the dialog. This option is unavailable if no nodes are selected, or if features other than nodes are selected (e.g. vertices, arcs, or disjoint points). This option can only be used by itself, since it is an interactive operation while the others are automated.

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.

  1. 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 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 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 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 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 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 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 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 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.