Work with utility elements

An array of analysis and tracing options usually begin with or include a utility element in the result. This element corresponds to a network feature or object that contains additional information such as a terminal or fraction along value that affects the analysis. For example, the utility element's terminal may limit the number of connectivity associations or change the direction of a trace, while its fraction along value may return a partial geometry from a trace.

This utility element may be created from a feature or asset type with a global id. The feature may be a result of a query or identify operation on a layer or table that is part of the utility network.

Utility element from a feature

You may query for a specific feature using any of its fields or geometry or interactively identify a feature in a map view. When using identify, the feature may be found in the GeoElement list immediately under IdentifyLayerResult when part of a FeatureLayer or from sublayerResults() when part of a SubtypeFeatureLayer.

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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
    // Create a query parameters
    QueryParameters queryParameters;

    // Set the where clause on the query parameters
    queryParameters.setWhereClause("GlobalId like '{D353C10C-E617-4618-BDD0-B48EDB822D07}'");

    // Execute an asynchronous query on the feature table using the query parameters resulting
    // in a feature query result (via QFuture)
    featureTable->queryFeaturesAsync(queryParameters, this).then
        (this, [] (FeatureQueryResult* featureQueryResult)
    {
        // Get a feature iterator from the feature query result
        FeatureIterator featureIterator = featureQueryResult->iterator();

        // Get a QList of features from the feature iterator
        QList<Feature*> features = featureIterator.features();

        // Get the first feature from the QList of features
        Feature* feature = features.first();

        // Cast the feature to an ArcGIS feature
        ArcGISFeature* arcgisFeature = dynamic_cast<ArcGISFeature*>(feature);
    });
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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
    // Execute an asynchronous identify on the map view using the map's screen point, a tolerance of
    // 5 pixels, and a boolean of false (without returning a popups). This returns in an identify
    // layer results. This is done via a QFuture.
    m_mapView->identifyLayersAsync(screenPoint, 5, false, this).then
        (this, [] (QList<IdentifyLayerResult*> identifyLayerResults)
    {
        // Create an empty ArcGIS feature (we will populate it later)
        ArcGISFeature* arcgisFeature = nullptr;

        // Loop through the identify layer results
        for (IdentifyLayerResult* identifyLayerResult : identifyLayerResults)
        {
            // Cast the identify layer result's layer content to a sub feature layer
            SubtypeFeatureLayer* subtypeFeatureLayer = dynamic_cast<SubtypeFeatureLayer*>
                (identifyLayerResult->layerContent());

            // Cast the identify layer result's layer content to a feature layer
            FeatureLayer* featureLayer = dynamic_cast<FeatureLayer*>(identifyLayerResult->layerContent());

            // If we have a sub type feature layer (i.e. not null), continue processing
            if (subtypeFeatureLayer)
            {
                // Get the QList of identify layer results from the sub layer results of the identify
                QList<IdentifyLayerResult*> sublayerIdentifyLayerResults =
                    identifyLayerResult->sublayerResults();

                // Loop thru the identify layer results for the sub layer
                for (IdentifyLayerResult* sublayerIdentifyLayerResult : sublayerIdentifyLayerResults)
                {
                    // Get the QList of geo elements of the the sub layer identify layer result
                    QList<GeoElement*> geoElements = sublayerIdentifyLayerResult->geoElements();

                    // Test if the ArcGIS feature was previously nullptr
                    if (arcgisFeature)
                        break;

                    // Loop through the geo elements
                    for (GeoElement* geoElement : geoElements)
                    {
                        // Test if the ArcGIS feature was previously nullptr
                        if (arcgisFeature)
                            break;

                        // Cast the geo element to the ArcGIS feature
                        arcgisFeature = dynamic_cast<ArcGISFeature*>(geoElement);
                    }
                }
            }

            // If we have a feature layer (i.e. not null), continue processing
            if (featureLayer)
            {
                // Get the QList of geo elements of the the identify layer result
                QList<GeoElement*> geoElements = identifyLayerResult->geoElements();

                // Test if the ArcGIS feature was previously nullptr
                if (arcgisFeature)
                    break;

                // Loop through the geo elements
                for (GeoElement* geoElement : geoElements)
                {
                    // Test if the ArcGIS feature was previously nullptr
                    if (arcgisFeature)
                        break;

                    // Cast the geo element to the ArcGIS feature
                    arcgisFeature = dynamic_cast<ArcGISFeature*>(geoElement);
                }
            }
        }
    });
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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
// Create a utility element for the feature
UtilityElement* utilityElement = utilityNetwork->createElementWithArcGISFeature(
      feature, /*UtilityTerminal* */ nullptr, this);

Utility element from an asset type

An asset type can come from another utility element or be derived from a feature in the utility network, except from a subnet line table that does not have an asset type. You can use the feature's table name to get its network source. Use the network source and the feature's subtype to get its asset group. From the asset group, you can select an asset type by name or code.

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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
    // Option 1: Creating utility element from another utility element's asset type
    // ----------------------------------------------------------------------------

    // Get the utility asset type from a another utility element
    UtilityAssetType* option1UtilityAssetType = otherUtilityElement->assetType();

    // Make a new utility element using an asset type and guid
    UtilityElement* option1UtilityElement =
        utilityNetwork->createElementWithAssetType(option1UtilityAssetType, globalId);


    // Option 2: Creating a utility element from a feature in a utility network
    // ----------------------------------------------------------------------------

    // Get the feature table from a feature
    FeatureTable* featureTable = feature->featureTable();

    // Get the name from the feature table
    QString featureTableName = featureTable->tableName();

    // Get the utility network definition from the utility network
    UtilityNetworkDefinition* utilityNetworkDefinition = utilityNetwork->definition();

    // Get the utility network source from the utility network definition
    UtilityNetworkSource* utilityNetworkSource = utilityNetworkDefinition->networkSource(featureTableName);

    // Get an ArcGIS feature from a feature (via casting)
    ArcGISFeature* arcgisFeature = dynamic_cast<ArcGISFeature*>(feature);

    // Get the feature sub type from the ArcGIS feature
    FeatureSubtype featureSubtype = arcgisFeature->featureSubtype();

    // Get the sub type name from the feature sub type
    QString subtypeName = featureSubtype.name();

    // Get the utillity asset group from the network source via it's sub type name
    UtilityAssetGroup* utilityAssetGroup = utilityNetworkSource->assetGroup(subtypeName);

    // Get the attribute list model from the feature
    AttributeListModel* attributeListModel = feature->attributes();

    // Get the attribute value of "ASSETTYPE" from the attribute list model
    QVariant assetTypeCode = attributeListModel->attributeValue("ASSETTYPE");

    // Get the QList of utility asset types from the asset group
    QList<UtilityAssetType*> utilityAssetTypes = utilityAssetGroup->assetTypes();

    // Get the first utility asset type from the QList of utility asset types
    UtilityAssetType* firstUtilityAssetType = utilityAssetTypes.first();

    // Get the first utility asset type's code from the utility asset type
    int firstUtilityAssetTypeCode = firstUtilityAssetType->code();

    // Test if the first utility asset type's code is the same as the attribute value of "ASSETTYPE"
    // from the attribute list model, if true continue processing
    if (firstUtilityAssetTypeCode == assetTypeCode)
    {
        // Get the utility network source of "Electric Distribution Device" from the utility
        // netowrk defintion
        utilityNetworkSource = utilityNetworkDefinition->networkSource("Electric Distribution Device");

        // Get the asset group of "Service Point" from the utility network source
        utilityAssetGroup = utilityNetworkSource->assetGroup("Service Point");

        // Get the utility asset type of "Single Phase Low Voltage Meter" from the utility
        // asset group
        UtilityAssetType* option2UtilityAssetType =
            utilityAssetGroup->assetType("Single Phase Low Voltage Meter");

        // Make a new utility element using an asset type (from the first utility asset type found
        // in the feature) and guid
        UtilityElement* option2UtilityElement =
            utilityNetwork->createElementWithAssetType(option2UtilityAssetType, globalId);
    }

Utility element properties

A terminal is required when a UtilityElement that supports more than one terminal is used in a trace and optional when used to get associations. Terminals impact traces and connectivity associations.

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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
// Get the terminals for the feature
QList<UtilityTerminal*> utilityTerminals = utilityElement->assetType()->terminalConfiguration()->terminals();

// Select the first terminal if present
if (utilityTerminals.count() > 0)
  utilityElement->setTerminal(utilityTerminals.first());

If the feature represents a line, you can optionally specify a location along the line to use as a trace location. This value is a percentage of the length of the line, beginning from the line's 'from' point.

Use UtilityElement::fractionAlongEdge() to define the location of the point along the line.

The following example uses the GeometryEngine to get the fraction of a tap location along the line.

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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
// Compute how far tapped location is along the edge feature
if (feature->geometry().geometryType() == GeometryType::Polyline)
{
  const Polyline line = geometry_cast<Polyline>(GeometryEngine::removeZ(feature->geometry()));

  // Set how far the element is along the edge
  utilityElement->setFractionAlongEdge(GeometryEngine::fractionAlong(line, clickPoint, -1));
}

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