Trace utility network

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Discover connected features in a utility network using connected, subnetwork, upstream, and downstream traces.

Image of trace utility network

Use case

You can use a trace to visualize and validate the network topology of a utility network for quality assurance. Subnetwork traces are used for validating whether subnetworks, such as circuits or zones, are defined or edited appropriately.

How to use the sample

Tap on one or more features while 'Add starting locations' or 'Add barriers' is selected. When a junction feature is identified, you may be prompted to select a terminal. When an edge feature is identified, the distance from the tapped location to the beginning of the edge feature will be computed. Select the type of trace using the drop down menu. Tap 'Trace' to initiate a trace on the network. Tap 'Reset' to clear the trace parameters and start over.

How it works

  1. Create a MapView and subscribe to its GeoViewTapped event.
  2. Create and load a ServiceGeodatabase with a feature service URL and get tables by their layer IDs.
  3. Create a Map that contains FeatureLayer(s) created from the ServiceGeodatabase's tables.
  4. Create and load a UtilityNetwork with the same feature service URL and this Map.
  5. Add a GraphicsOverlay with symbology that distinguishes starting locations from barriers.
  6. Identify features on the map and add a Graphic that represents its purpose (starting location or barrier) at the tapped location.
  7. Create a UtilityElement for the identified feature.
  8. Determine the type of this element using its UtilityNetworkSource.SourceType property.
  9. If the element is a junction with more than one terminal, display a terminal picker. Then set the junction's UtilityTerminal property with the selected terminal.
  10. If an edge, set its FractionAlongEdge property using GeometryEngine.FractionAlong.
  11. Add this UtilityElement to a collection of starting locations or barriers.
  12. Create UtilityTraceParameters with the selected trace type along with the collected starting locations and barriers (if applicable).
  13. Set the UtilityTraceParameters.TraceConfiguration with the tier's UtilityTier.GetDefaultTraceConfiguration() result.
  14. Run a UtilityNetwork.TraceAsync with the specified parameters.
  15. For every FeatureLayer in the map, select the features returned with GetFeaturesForElementsAsync from the elements matching their UtilityNetworkSource.FeatureTable with the layer's FeatureTable.

Relevant API

  • FractionAlong
  • ServiceGeodatabase
  • UtilityAssetType
  • UtilityDomainNetwork
  • UtilityElement
  • UtilityElementTraceResult
  • UtilityNetwork
  • UtilityNetworkDefinition
  • UtilityNetworkSource
  • UtilityTerminal
  • UtilityTier
  • UtilityTraceConfiguration
  • UtilityTraceParameters
  • UtilityTraceResult
  • UtilityTraceType
  • UtilityTraversability

About the data

The Naperville electrical network feature service contains a utility network used to run the subnetwork-based trace shown in this sample. 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

condition barriers, downstream trace, network analysis, subnetwork trace, trace configuration, traversability, upstream trace, utility network, validate consistency

Sample Code

TraceUtilityNetwork.xamlTraceUtilityNetwork.xamlTraceUtilityNetwork.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.TraceUtilityNetwork.TraceUtilityNetwork"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <esriUI:MapView x:Name="MyMapView"
                        Grid.Row="0"
                        Grid.RowSpan="2"
                        GeoViewTapped="OnGeoViewTapped" />
        <Grid x:Name="StatusGrid">
            <Label x:Name="Status"
                   Grid.Row="0"
                   Margin="5"
                   HorizontalOptions="FillAndExpand"
                   Text="Loading sample..."
                   TextColor="White" />
        </Grid>
        <StackLayout x:Name="BusyIndicator"
                     Grid.Row="0"
                     Grid.RowSpan="2"
                     HeightRequest="40"
                     IsVisible="False"
                     VerticalOptions="Center">
            <ActivityIndicator HeightRequest="40"
                               HorizontalOptions="Center"
                               IsRunning="True"
                               VerticalOptions="Center">
                <ActivityIndicator.Color>
                    <OnPlatform x:TypeArguments="Color" iOS="#2499CE" />
                </ActivityIndicator.Color>
            </ActivityIndicator>
        </StackLayout>
        <Grid x:Name="PickerUI"
              Grid.Row="0"
              IsVisible="False">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Label Grid.Row="0"
                   Margin="5"
                   HorizontalTextAlignment="Center"
                   Text="Choose a terminal for this junction." />
            <ListView x:Name="TerminalPicker"
                      Grid.Row="1"
                      ItemSelected="Terminal_Selected" />
        </Grid>
        <StackLayout x:Name="MainUI"
                     Grid.Row="2"
                     Orientation="Vertical">
            <Button x:Name="TracePickerButton"
                    Clicked="TraceTypeButtonPressed"
                    Text="Trace type: Connected" />
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.23*" />
                    <ColumnDefinition Width="0.23*" />
                    <ColumnDefinition Width="0.08*" />
                    <ColumnDefinition Width="0.23*" />
                    <ColumnDefinition Width="0.23*" />
                </Grid.ColumnDefinitions>
                <Button x:Name="IsAddingStartingLocations"
                        Grid.Column="0"
                        Clicked="IsAddingStartingLocations_Clicked"
                        HorizontalOptions="FillAndExpand"
                        IsEnabled="False"
                        Text="Origin" />
                <Button x:Name="IsAddingBarriers"
                        Grid.Column="1"
                        Clicked="IsAddingBarriers_Clicked"
                        HorizontalOptions="FillAndExpand"
                        Text="Barrier" />
                <Grid Grid.Column="2" />
                <Button Grid.Column="3"
                        Clicked="OnReset"
                        HorizontalOptions="FillAndExpand"
                        Text="Reset" />
                <Button Grid.Column="4"
                        Clicked="OnTrace"
                        HorizontalOptions="FillAndExpand"
                        Text="Trace" />
            </Grid>
        </StackLayout>
    </Grid>
</ContentPage>

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