Display utility associations

View inWPFUWPFormsiOSAndroid
View on GitHub
Sample viewer app

Create graphics for utility associations in a utility network.

Image of display utility associations

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

  1. Create and load a UtilityNetwork with a feature service URL.
  2. Add a FeatureLayer to the map for every UtilityNetworkSource of type Edge or Junction.
  3. Create a GraphicsOverlay for the utility associations.
  4. Add an event handler for the ViewpointChanged event of the MapView.
  5. When the sample starts and every time the viewpoint changes, do the following steps.
  6. Get the geometry of the mapview's extent using GetCurrentViewpoint(ViewpointType.BoundingGeometry)?.TargetGeometry?.Extent.
  7. Get the associations that are within the current extent using GetAssociationsAsync(extent).
  8. Get the UtilityAssociationType for each association.
  9. Create a Graphic using the Geometry property of the association and a preferred symbol.
  10. 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

DisplayUtilityAssociations.xamlDisplayUtilityAssociations.xaml.cs
                                  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<UserControl
    x:Class="ArcGISRuntime.WPF.Samples.DisplayUtilityAssociations.DisplayUtilityAssociations"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <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>
        <esri:MapView x:Name="MyMapView" NavigationCompleted="OnNavigationCompleted" />
        <Border Style="{StaticResource BorderStyle}">
            <StackPanel>
                <Label Margin="5" Content="Utility association types" />
                <ListView
                    x:Name="AssociationLegend"
                    Margin="5"
                    IsHitTestVisible="False"
                    ItemTemplate="{StaticResource AssociationLegendItemTemplate}" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.