SnapRules

class SnapRules

A table of snapping rules to apply to one or more SnapSource objects When using the GeometryEditor to edit the geometry of features that participate in a utility network, rule-based snapping can be configured on SnapSettings. Utility networks rely on geometric coincident-based connectivity to provide pathways for resources, and snapping can be a useful tool to help maintain those pathways. A utility network contains rules for connectivity, and using rule-based snapping respects the rules for the specific feature type being edited, based on its asset type and asset group, helping maintain network connectivity.

To use rule-based snapping to edit a specific com.arcgismaps.utilitynetworks.UtilityAssetType:

  1. Connect a GeometryEditor to the map view, and ensure the com.arcgismaps.mapping.view.MapView.map is set and contains the pertinent utility network(s).

    • See GeometryEditor for more information about general GeometryEditor set up and configuration.

    • The com.arcgismaps.mapping.ArcGISMap.operationalLayers collection should include, at a minimum, the layer you wish to edit, and the layers that have connectivity with the edit layer that will be used for snapping. The utility network data model makes use of sublayers, and adding the layers using com.arcgismaps.mapping.layers.SubtypeFeatureLayer offers the ability to change visibility and enable or disable snapping for specific subtypes. If you are programmatically adding layers to the map, ensure that you use a com.arcgismaps.data.ServiceGeodatabase when adding multiple layers from the same feature service.

  2. Get the com.arcgismaps.utilitynetworks.UtilityNetwork that you will be working with.

  3. Create a SnapRules object appropriate for use with the utility network and asset type you will edit:

  4. Get the GeometryEditor.snapSettings, and ensure SnapSettings.isEnabled and SnapSettings.isFeatureSnappingEnabled are true.

  5. Call SnapSettings.syncSourceSettings, passing in the snap rules you created previously, and SnapSourceEnablingBehavior.SetFromRules.

  6. Call GeometryEditor.start passing in the com.arcgismaps.mapping.GeoElement.geometry of the feature you wish to edit, or GeometryEditor.start if you have no initial geometry.

    • The user can interactively edit the feature geometry.

  7. When edits are complete, set the feature geometry with the result of GeometryEditor.stop.

After calling SnapSettings.syncSourceSettings, each SnapSourceSettings in SnapSettings.sourceSettings is configured with the appropriate SnapSourceSettings.ruleBehavior based on the connectivity rules specified in the utility network. For details, see SnapRuleBehavior.

Ensure that your com.arcgismaps.utilitynetworks.UtilityNetwork and the layers in the map that you will snap to use the same feature tables. For more information, see SnapRules.create.

Utility network features are z-aware - each feature geometry includes z-values (com.arcgismaps.geometry.Geometry.hasZ is true). Two points, or vertices, are geometrically coincident when the x, y, and z-values of the points or vertices are equal. When you configure rule-based snapping, by calling SnapSettings.syncSourceSettings, any edits made using snapping will use the z-value of the feature geometry from the SnapSource, if that snap source geometry is z-aware. If multiple snap candidates exist at the same location, then the default z-value is used instead.

Since

200.7.0

See also

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Gets the applicable SnapRuleBehavior for the given SnapSource. This method can be used to check SnapRuleBehavior of a valid SnapSource directly, without needing to synchronize the SnapSettings.sourceSettings collection on SnapSettings and get SnapSourceSettings.ruleBehavior.