Trace utility network

View inQMLC++
View on GitHub
Sample viewer app

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

screenshot

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. Click 'Trace' to initiate a trace on the network. Click 'Reset' to clear the trace parameters and start over.

How it works

  1. Create a MapView and connect to its mouseClicked signal.
  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 as the 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 point or barrier) at the location of each identified feature.
  7. Create a UtilityElement for the identified feature.
  8. Determine the type of this element using its NetworkSource::SourceType property.
  9. If the element is a junction with more than one terminal, display a terminal picker. Then set the junction's terminal 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 utility tier's traceConfiguration property.
  14. Run a UtilityNetwork::trace with the specified parameters.
  15. For every FeatureLayer in the map, select the features using the UtilityElement::objectId from the filtered list of UtilityElementTraceResult::elements.

Relevant API

  • GeometryEngine::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, hosted on ArcGIS Online, contains a utility network used to run the subnetwork-based trace shown in this sample.

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.

Credentials:

  • Username: viewer01
  • Password: I68VGU^nMurF

Tags

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

Sample Code

TraceUtilityNetwork.qmlTraceUtilityNetwork.cppTraceUtilityNetwork.h
                                                                                                                                                           
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// [WriteFile Name=TraceUtilityNetwork, Category=UtilityNetwork]
// [Legal]
// Copyright 2019 Esri.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]

import QtQuick 2.6
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import Esri.Samples 1.0

Item {

    // add a mapView component
    MapView {
        id: view
        anchors.fill: parent
    }

    // Declare the C++ instance which creates the scene etc. and supply the view
    TraceUtilityNetworkSample {
        id: model
        mapView: view
    }

    Dialog {
        modal: true
        standardButtons: Dialog.Ok | Dialog.Cancel
        x: (parent.width - width) / 2
        y: (parent.height - height) / 2
        visible: model.terminalDialogVisisble

        ColumnLayout {
            Text {
                text: qsTr("Select the terminal for this junction.")
                Layout.alignment: Qt.AlignHCenter
            }

            ComboBox {
                id: terminalSelection
                model: ["High", "Low"]
                Layout.alignment: Qt.AlignHCenter
            }
        }

        onAccepted: model.multiTerminalIndex(terminalSelection.currentIndex);
    }

    Dialog {
        modal: true
        standardButtons: Dialog.Ok
        x: (parent.width - width) / 2
        y: (parent.height - height) / 2
        visible: model.dialogVisible

        Text {
            text: model.dialogText
            anchors.centerIn: parent
        }
    }

    BusyIndicator {
        id: busy
        anchors.centerIn: parent
        visible: model.busy
    }

    Rectangle {
        id: backBox
        anchors {
            left: parent.left
            top: parent.top
            margins: 3
        }
        width: childrenRect.width
        height: childrenRect.height
        color: "lightgrey"
        opacity: 0.8
        radius: 5

        // catch mouse signals from propagating to parent
        MouseArea {
            anchors.fill: parent
            onClicked: mouse.accepted = true
            onWheel: wheel.accepted = true
        }

        Column {

            GridLayout {
                columns: 2
                rows: 3
                flow: GridLayout.LeftToRight
                RadioButton {
                    id: startingLocBtn
                    Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                    checked: true
                    text: qsTr("Add starting location(s)")
                    onToggled: model.startingLocationsEnabled = checked;
                }

                RadioButton {
                    id: barriersBtn
                    Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                    text: qsTr("Add barrier(s)")
                    onToggled: model.startingLocationsEnabled = !checked;
                }

                Text {
                    text: qsTr("Trace Type:")
                    Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                }

                ComboBox {
                    id: traceTypes
                    Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                    model: ["Connected", "Subnetwork", "Upstream", "Downstream"]
                }

                Button {
                    id: resetBtn
                    text: qsTr("Reset")
                    Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                    enabled: !busy.visible
                    onClicked: model.reset();
                }

                Button {
                    id: traceBtn
                    text: qsTr("Trace")
                    Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                    enabled: !busy.visible
                    onClicked: model.trace(traceTypes.currentIndex);
                }
            }

            Text {
                // Displays fraction along edge or if a junction is selected
                text: model.junctionSelected ? qsTr("Junction selected") : qsTr("Fraction along edge: %1".arg(model.fractionAlongEdge.toFixed(6)))
                anchors.horizontalCenter: parent.horizontalCenter
            }

        }
    }
}

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