Class SnapRules
A table of snapping rules to apply to one or more ISnapSource objects
Inheritance
Namespace: Esri.ArcGISRuntime.UI.Editing
Assembly: Esri.ArcGISRuntime.dll
Syntax
public sealed class SnapRules
Remarks
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 UtilityAssetType:
-
Connect a GeometryEditor to the map view, and ensure the Map is set and contains the
pertinent utility network(s).
- See GeometryEditor for more information about general GeometryEditor set up and configuration.
- The 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 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 ServiceGeodatabase when adding multiple layers from the same feature service.
-
Get the UtilityNetwork that you will be working with.
- If you are opening a web map or MobileMapPackage, the UtilityNetworks collection may already contain the relevant utility network. Alternatively you may get the utility network from the same Geodatabase that backs your operational layers, or call UtilityNetwork(Uri, Map) to create the network from a feature service URI and associate it with your Map.
-
Create a SnapRules object appropriate for use with the utility network and asset type you will edit:
- If you know the UtilityAssetType, you can pass this to CreateAsync(UtilityNetwork, UtilityAssetType). For example, if you have identified an existing feature to be edited, you can call CreateElement(ArcGISFeature), then get AssetType.
- If you have a set of Attributes, you can pass these to CreateAsync(UtilityNetwork, FeatureTable, IEnumerable<KeyValuePair<String, Object>>). For example, you may be creating a new feature from a FeatureTemplate or by using a FeatureForm.
-
Get the SnapSettings, and ensure IsEnabled
and IsFeatureSnappingEnabled are
true
. -
Call SyncSourceSettings(SnapRules, SnapSourceEnablingBehavior),
passing in the snap rules you created previously, and
SetFromRules.
- If your workflow has previously synchronized snap sources, consider if Preserve is more appropriate instead.
-
Call Start(Geometry) passing in the
Geometry of the feature you wish to edit, or
Start(GeometryType) if you have no initial geometry.
- The user can interactively edit the feature geometry.
- When edits are complete, set the feature geometry with the result of Stop().
After calling SyncSourceSettings(SnapRules, SnapSourceEnablingBehavior), each SnapSourceSettings in SourceSettings is configured with the appropriate RuleBehavior based on the connectivity rules specified in the utility network. For details, see SnapRuleBehavior.
Ensure that your UtilityNetwork and the layers in the map that you will snap to use the same feature tables. For more information, see CreateAsync(UtilityNetwork, UtilityAssetType).
Utility network features are z-aware — each feature geometry includes z-values (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
SyncSourceSettings(SnapRules, SnapSourceEnablingBehavior), any edits made using snapping will
use the z-value of the feature geometry from the ISnapSource, 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.
See also: Network Rules ArcGIS Pro help topic
Methods
Name | Description |
---|---|
CreateAsync(UtilityNetwork, FeatureTable, IEnumerable<KeyValuePair<String, Object>>) | Analyzes a UtilityNetwork for the rules which allow or limit the snapping of a feature in the given featureTable with the given attributes, and returns a SnapRules which can be used to configure interactive snapping behavior in a GeometryEditor. |
CreateAsync(UtilityNetwork, UtilityAssetType) | Analyzes a UtilityNetwork for the rules which allow or limit the snapping of the given UtilityAssetType to other features, and returns a SnapRules which can be used to configure interactive snapping behavior in a GeometryEditor. |
GetRuleBehavior(ISnapSource) | Returns the applicable SnapRuleBehavior for the given ISnapSource. |
See Also
Applies to
Target | Versions |
---|---|
.NET Standard 2.0 | 200.7 |
.NET | 200.7 |
.NET Windows | 200.7 |
.NET Android | 200.7 |
.NET iOS | 200.7 |
.NET Framework | 200.7 |
UWP | 200.7 |