Create graphics for utility associations in a utility network.
Use case
Visualizing utility associations can help you to better understand trace results and the topology of your utility network. For example, connectivity associations allow you to model connectivity between two junctions that don't have geometric coincidence (are not in the same location); structural attachment associations allow you to model equipment that may be attached to structures; and containment associations allow you to model features contained within other features.
How to use the sample
Pan and zoom around the map. Observe graphics that show utility associations between junctions.
How it works
- Create and load a
UtilityNetwork
with a feature service URL. - Add a
FeatureLayer
to the map for everyUtilityNetworkSource
of typeEdge
orJunction
. - Create a
GraphicsOverlay
for the utility associations. - Add an event handler for the
ViewpointChanged
event of theMapView
. - When the sample starts and every time the viewpoint changes, do the following steps.
- Get the geometry of the mapview's extent using
GetCurrentViewpoint(ViewpointType.BoundingGeometry)?.TargetGeometry?.Extent
. - Get the associations that are within the current extent using
GetAssociationsAsync(extent)
. - Get the
UtilityAssociationType
for each association. - Create a
Graphic
using theGeometry
property of the association and a preferred symbol. - Add the graphic to the graphics overlay.
Relevant API
- GraphicsOverlay
- UtilityAssociation
- UtilityAssociationType
- UtilityNetwork
About the data
The feature service in this sample represents an electric network in Naperville, Illinois, which contains a utility network used to run the subnetwork-based trace.
Additional information
Using utility network on ArcGIS Enterprise 10.8 requires an ArcGIS Enterprise member account licensed with the Utility Network user type extension. Please refer to the utility network services documentation.
Tags
associating, association, attachment, connectivity, containment, relationships
Sample Code
<UserControl
x:Class="ArcGIS.UWP.Samples.DisplayUtilityAssociations.DisplayUtilityAssociations"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<UserControl.Resources>
<DataTemplate x:Key="AssociationLegendItemTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image
Width="25"
Height="25"
Source="{Binding Value}" />
<TextBlock Grid.Column="1" Text="{Binding Key}" />
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid>
<esriUI:MapView x:Name="MyMapView" NavigationCompleted="OnNavigationCompleted" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<TextBlock Margin="5" Text="Utility association types" />
<ListView
x:Name="AssociationLegend"
Margin="5"
IsHitTestVisible="False"
ItemTemplate="{StaticResource AssociationLegendItemTemplate}" />
</StackPanel>
</Border>
</Grid>
</UserControl>