SnapRules class final
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 UtilityAssetType:
- Connect a GeometryEditor to the map view, and ensure the
ArcGISMapViewController.arcGISMap is set and contains the pertinent
utility network(s).
- See GeometryEditor for more information about general GeometryEditor set up and configuration.
- The GeoModel.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 ArcGISMap.utilityNetworks collection may already contain the relevant utility network. Alternatively you may get the utility network from the same Geodatabase or ServiceGeodatabase that backs your operational layers.
- 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 SnapRules.createFromAssetType. For example, if you have identified an existing feature to be edited, you can call UtilityNetwork.createElement, then get UtilityElement.assetType.
- If you have a set of Feature.attributes, you can pass these to SnapRules.createFromAttributes. For example, you may be creating a new feature from a FeatureTemplate or by using a FeatureForm.
- Get the GeometryEditor.snapSettings, and ensure SnapSettings.isEnabled and SnapSettings.isFeatureSnappingEnabled are true.
- Call SnapSettings.syncSourceSettingsUsingRules, passing in the snap
rules you created previously, and SnapSourceEnablingBehavior.setFromRules.
- If your workflow has previously synchronized snap sources, consider if SnapSourceEnablingBehavior.preserve is more appropriate instead.
- Call GeometryEditor.startWithGeometry passing in the
GeoElement.geometry of the feature you wish to edit, or
GeometryEditor.startWithGeometryType 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 GeometryEditor.stop.
After calling SnapSettings.syncSourceSettingsUsingRules, 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 UtilityNetwork and the layers in the map that you will snap to use the same feature tables. For more information, see SnapRules.createFromAssetType.
Utility network features are z-aware - each feature geometry includes z-values (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.syncSourceSettingsUsingRules, 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.
- Implemented types
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getRuleBehavior(
{required SnapSource source}) → SnapRuleBehavior - Gets the applicable SnapRuleBehavior for the given SnapSource.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
createFromAssetType(
{required UtilityNetwork utilityNetwork, required UtilityAssetType assetType}) → Future< SnapRules> - Analyzes an 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.
-
createFromAttributes(
{required UtilityNetwork utilityNetwork, required FeatureTable featureTable, required Map< CaseInsensitiveString, dynamic> attributes}) → Future<SnapRules> - Analyzes an 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.