ArcGIS Blog

Developers

ArcGIS Maps SDK for .NET

How to perform snap geometry edits with utility network connectivity rules

By Hamish Duff

Introduction

Utility networks are advanced systems used to model and analyze complex infrastructure such as gas, electricity, water, and telecommunications. These networks provide a comprehensive framework for representing the connectivity and behavior of utility systems in a geospatial environment.

Accurate representation of these systems is crucial for maintaining data integrity and supporting efficient utility operations. With the latest 200.7 release of the ArcGIS Maps SDK for Native Apps, the GeometryEditor now includes rule-based snapping capabilities, significantly enhancing the accuracy and efficiency of geometry editing tasks.

In this blog, we will explore how to use utility network connectivity rules when editing geometries. You will learn how to create and configure snap rules, understand SnapRuleBehavior, and perform additional utility network operations to optimize your workflow.

The concepts shared here apply to the Qt, Kotlin, Swift and .NET Maps SDKs in the ArcGIS Maps SDKs for Native Apps suite, with the code snippets shared using the .NET Maps SDK.

 

What are network rules?

Utility networks use network rules to dictate which network features can connect or associate in the utility network based on their specified asset types.

Note: Asset type refers to the combined network source id, asset group code and asset type code.

Network rules fall into a number of categories:

  • Junction-edge connectivity
  • Junction-junction connectivity
  • Edge-junction-edge connectivity
  • Structural attachment
  • Containment

Snap rules can be created, for use in the geometry editor, using a subset of the connectivity rules in a network.

Note: Structural attachment and containment rules are not related to spatial connectivity and so are not utilized in the creation of snap rules.

Connectivity rules as snap rules

The following image displays an example of each connectivity rule. More information can be found in the ArcGIS Pro documentation.

Junction-junction connectivity rules govern the ability for point features or junction objects to connect where they may or may not be geometrically coincident. These rules are typically used to support terminal connectivity. As they do not necessarily require geometric coincidence, they are not used when creating snap rules.

Junction-edge connectivity rules govern connectivity between point and line objects. These rules are predominantly used for spatial connectivity and so are used when creating snap rules. These rules also operate in both directions, that is if a rule exists that allows a specified junction to snap to a specified edge then the edge will also be allowed to snap to the junction.

Edge-junction-edge connectivity rules govern the ability for line features or edge objects to connect using an intermediate junction feature or junction object. These rules are useful to ensure a line does not terminate with a junction (because junctions should connect two features or objects). These rules are not taken into account when creating snap rules.

While no edge-edge connectivity rules exist, additional snap rules are created for edges to allow snapping to endpoint vertices of other edges with the same asset type e.g. to extend cable or pipes.

Note: The same asset type means the network source id, asset group code and asset type code are the same.

Connectivity Rule Used in snap rules
Junction-junction
Junction-edge
Edge-junction-edge
Edge-edge (for same asset type)

How to create snap rules

You can create SnapRules in two different ways, and both require the utility network you are working with.

Using UtilityAssetType:

If you know the utility asset type, you can use this in conjunction with the utility network. This is particularly useful when editing an existing feature as you can call UtilityNetwork.CreateElement(arcGISFeature) and then get the UtilityElement.AssetType.


SnapRules snapRules = await SnapRules.CreateAsync(utilityNetwork, utilityAssetType);

Using feature attributes:

If you have a set of Feature.Attributes you can use these with the utility network and the FeatureTable associated with the feature to create snap rules. This is a good approach to use if you are creating a new feature using a FeatureTemplate.


SnapRules snapRules = await SnapRules.CreateAsync(utilityNetwork, featureTable, featureAttributes);

Configuring the geometry editor with snap rules

Ensure you have a geometry editor connected to your map view and your map view has a map containing the utility network you are working with. Then, using the snap rules you previously created, synchronize the snap sources in the geometry editor.


GeometryEditor.SnapSettings.SyncSourceSettings(snapRules, SnapSourceEnablingBehavior.SetFromRules);

Using SnapSourceEnablingBehavior.SetFromRules will enable snap sources for which snap rules are having an effect. This effect is described by a SnapRuleBehavior which I cover in more detail later in this article.

Alternatively you can use SnapSourceEnablingBehavior.Preserve which will leave the SnapSourceSettings.IsEnabled properties unaffected when synchronizing the snap sources. This may be a useful approach to use if you are working with asset types that have rules for multiple snap sources but you know you only want to work with the same snap source regardless of the asset type.

After synchronizing the snap sources with the geometry editor, snap sources can be found in the GeometryEditor.SnapSettings.SnapSourceSettings collection. If your map includes SubtypeFeatureLayer snap sources, child SubtypeSublayer objects are included as snap sources in the parent SnapSourceSettings.ChildSnapSources collection in the same order as the SubtypeFeatureLayer.SubtypeSublayers collection.

Now that the snap sources have been synchronized with a set of snap rules, the geometry editor can be started and will use the snap rules for the asset type you are editing.

The geometry editor can be started with an existing geometry (for example from a feature that is being edited).


GeometryEditor.Start(existingFeature.Geometry);

Or with a GeometryType to create a new geometry.


GeometryEditor.Start(GeometryType.Point);

What does SnapRuleBehavior mean?

After synchronizing your geometry editor with a set of snap rules, each of your snap sources will be marked with a SnapRuleBehavior. This is an indication of the presence and impact of snap rules on your snap source. Here is a short overview of what these different values mean and the situations you may come across them:

SnapRuleBehavior.None

This means the snap source is not a part of the utility network that you created the snap rules with. No connectivity rules exist and so SnapRules have no influence here – snapping can freely occur to any geometry in this snap source (assuming the source is enabled for snapping). Typically you will see this value when working with a graphics overlay or a feature layer that is not a part of the utility network.

SnapRuleBehavior.RulesLimitSnapping

The snap source is a part of the utility network, rules exist such that snapping can occur between your chosen asset type and at least one asset type in the snap source.

SnapRuleBehavior.RulesPreventSnapping

The snap source is a part of the utility network and no rules exist between your chosen asset type and any asset type in the snap source. No snapping will occur whether the snap source is enabled or disabled.

Additional utility network operations

Editing utility network feature geometry with snap rules helps to ensure your edits result in valid connections. Should you wish to perform topology validation after making edits, or perform a network trace, check out the links to utility network samples in the next section.

Summary

The geometry editor with snap rules is a powerful tool to help you make efficient and accurate edits to features in a utility network. In this article I’ve given an overview of what utility networks and utility network rules are and why maintaining utility networks with precise edits is an important workflow. I’ve explained how new functionality coming in 200.7 allows you to use utility network connectivity rules to create snap rules and how these snap rules can be used to configure your geometry editor.

We’d love to know what apps you’re building and to hear your feedback on our new rule based snapping functionality. Suggestions are welcome over on our Esri Community Forums.

If you’d like to know more about utility network and editing geometries please have a look at the related articles and samples below.

To see an example of snapping with utility network connectivity rules as part of a larger feature editing workflow take a look at our 2025 Dev Summit plenary below.

Share this article