Display content of utility network container

View inWPFWinUIForms
View on GitHub

A utility network container allows a dense collection of features to be represented by a single feature, which can be used to reduce map clutter.

Image of display content of utility network container

Use case

Offering a container view for features aids in the review for valid structural attachment and containment relationships and helps determine if a dataset has an association role set. Container views often model a cluster of electrical devices on a pole top or inside a cabinet or vault.

How to use the sample

Tap on a container feature to show all features inside the container. The container is shown as a polygon graphic with the content features contained within. The viewpoint and scale of the map are also changed to the container's extent. Connectivity and attachment associations inside the container are shown as red and blue dotted lines respectively.

How it works

  1. Load a web map that includes ArcGIS Pro Subtype Group Layers with only container features visible (i.e. fuse bank, switch bank, transformer bank, hand hole and junction box).
  2. Add a GraphicsOverlay for displaying a container view.
  3. Create and load a UtilityNetwork with the same feature service URL as the layers in the Map.
  4. Add an event handler for the GeoViewTapped event of the MapView.
  5. Identify a feature and create a UtilityElement from it.
  6. Get the associations for this element using GetAssociationsAsync(UtilityElement, UtilityAssociationType.Containment).
  7. Turn-off the visibility of all OperationalLayers.
  8. Get the features for the UtilityElement(s) from the associations using GetFeaturesForElementsAsync(IEnumerable<UtilityElement>)
  9. Add a Graphic with the same geometry and symbol as these features.
  10. Add another Graphic that represents the combined extents of these features.
  11. Get associations for this extent using GetAssociationsAsync(Envelope)
  12. Add a Graphic to represent the association geometry between them using a symbol that distinguishes between Attachment and Connectivity association type.
  13. Zoom to the combined extents of the features in the container.
  14. To exit the container view, clear the Graphics and zoom out to the previous extent.

Relevant API

  • SubtypeFeatureLayer
  • UtilityAssociation
  • UtilityAssociationType
  • UtilityElement
  • UtilityNetwork
  • UtilityNetworkDefinition

About the data

The Naperville electric feature service contains a utility network layer used to find associations shown in this sample. The Naperville electric containers webmap uses the same feature service endpoint and displays only container features. Authentication is required and handled within the sample code.

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

associations, connectivity association, containment association, structural attachment associations, utility network

Sample Code

DisplayUtilityNetworkContainer.xamlDisplayUtilityNetworkContainer.xamlDisplayUtilityNetworkContainer.xaml.cs
Use dark colors for code blocksCopy
                                              
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
35
36
37
38
39
40
41
42
43
44
45
46
<UserControl x:Class="ArcGISRuntime.WinUI.Samples.DisplayUtilityNetworkContainer.DisplayUtilityNetworkContainer"
             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" GeoViewTapped="MyMapView_GeoViewTapped" />
        <Border Style="{StaticResource BorderStyle}">
            <StackPanel>
                <TextBlock Margin="5" Text="Click an element to view its container." />
                <TextBlock Margin="5"
                           FontWeight="Bold"
                           Text="Utility association types" />
                <ListView x:Name="AssociationLegend"
                          Margin="5"
                          IsHitTestVisible="False"
                          ItemTemplate="{StaticResource AssociationLegendItemTemplate}" />
                <Button x:Name="CloseButton"
                        Margin="5"
                        Click="CloseButton_Click"
                        Content="Close container view"
                        Visibility="Collapsed" />
            </StackPanel>
        </Border>
        <ProgressBar x:Name="LoadingBar"
                     Width="200"
                     Height="25"
                     HorizontalContentAlignment="Center"
                     VerticalContentAlignment="Center"
                     IsIndeterminate="True"
                     Visibility="Visible" />
    </Grid>
</UserControl>

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