An array of analysis Analysis is a systematic examination of a problem that provides new information. Learn more and tracing options usually begin with or include a utility element A utility element is an entity in a utility network that corresponds to a feature or a part of a feature (for example, a terminal inside a device). Learn more in the result. This element corresponds to a network feature A feature is a single record, also known as a row, that represents a real-world entity. It typically contains a geometry (point, multipoint, polyline, or polygon) and attributes but it can also contain just attributes. Learn more or object that contains additional information such as a terminal A terminal represents logical ports, entries, or exit locations on a single device or junction object within a utility network. Each port can flow in or out. Each device can contain many terminals, all of which can be interconnected. Learn more or fraction along value that affects the analysis. For example, the utility element’s terminal may limit the number of connectivity associations An association is a relationship between two elements that is reflected in a utility network topology. Learn more or change the direction of a trace A trace is an action that analyzes the paths in a utility network and returns features based on connectivity or traversability from the specified starting points. Learn more , while its fraction along value may return a partial geometry A geometry is a geometric shape, such as a point, polyline, or polygon, that contains one or more coordinates and a spatial reference. Learn more from a trace.

This utility element may be created from a feature or asset type An asset type is a class that refines a utility element's classification within an asset group. For example, a power transformer is an asset type of the transformer asset group within an electric device network. Learn more with a global id. The feature may be a result of a query or identify Identify is a query based on a point on a map or scene that is used to find feature, graphic, or raster cell data. Learn more operation on a layer A layer is a reference to a collection of geographic data that is used to access and display data. The data for layers are typically provided by the basemap layer service and data services. Learn more or table A table is a non-spatial dataset in a feature service. All records in a table share the same set of fields. Learn more that is part of the utility network A utility network is a feature service that represents a utility system, such as water, gas, or electricity. A utility network provides the capabilities to visualize, edit, and analyze utility assets and data. Learn more .

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 A map view is a user interface that displays map layers and graphics in 2D. It controls the area (extent) of the map that is visible and supports user interactions such as pan and zoom. Learn more . When using identify Identify is a query based on a point on a map or scene that is used to find feature, graphic, or raster cell data. Learn more , 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.

let queryParameters = QueryParameters()
queryParameters.whereClause = "GlobalId like '{D353C10C-E617-4618-BDD0-B48EDB822D07}'"
let queryResult = try await table.queryFeatures(using: queryParameters)
let feature = queryResult.features().first
let identifyLayerResult = try await mapViewProxy.identify(on: layer, screenPoint: screenPoint, tolerance: 5)
// Identifies the first feature of the feature layer.
guard let firstFeature = identifyLayerResult.geoElements.first else { return }
let firstFeatureLayerFeature = firstFeature as? ArcGISFeature
// Identifies the first feature from the sublayers' result.
guard let firstSublayerResult = identifyLayerResult.sublayerResults.first else { return }
let firstSublayerFeature = firstSublayerResult.geoElements.first as? ArcGISFeature
try await firstSublayerFeature?.load()
guard let feature = firstSublayerFeature else { return }
let element = utilityNetwork.makeElement(arcGISFeature: feature)

Utility element from an asset type

An asset type An asset type is a class that refines a utility element's classification within an asset group. For example, a power transformer is an asset type of the transformer asset group within an electric device network. Learn more can come from another utility element A utility element is an entity in a utility network that corresponds to a feature or a part of a feature (for example, a terminal inside a device). Learn more 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 A network source is a feature table whose features comprise one of a utility network's datasets. Learn more . Use the network source and the feature’s subtype to get its asset group An asset group is the main classification of a utility element. Each asset group is then divided into a collection of asset types. Learn more . From the asset group, you can select an asset type by name or code.

// Gets the asset type from an element.
let assetType = otherElement.assetType
// Makes a new utility element from the asset type and global ID.
let element = utilityNetwork.makeElement(assetType: assetType, globalID: globalID)
// Gets the network source with the specified name.
guard let tableName = feature.table?.tableName else { return }
var networkSource = utilityNetwork.definition?.networkSource(named: tableName)
// Gets the asset group with the subtype name.
guard let subtypeName = feature.subtype?.name else { return }
var assetGroup = networkSource?.assetGroup(named: subtypeName)
// Gets an asset type from a feature's asset type code.
let assetTypeCode = feature.attributes["ASSETTYPE"] as? Int
guard let featureAssetType = assetGroup?.assetTypes.first(where: { $0.code == assetTypeCode }) else { return }
// Makes a new utility element with the feature's asset type.
let element1 = utilityNetwork.makeElement(assetType: featureAssetType, globalID: globalID)
// Gets the asset type by name.
networkSource = utilityNetwork.definition?.networkSource(named: "Electric Distribution Device")
assetGroup = networkSource?.assetGroup(named: "Service Point")
guard let lowVoltageAssetType = assetGroup?.assetType(named: "Single Phase Low Voltage Meter") else { return }
// Makes a new utility element with the low voltage asset type.
let element2 = utilityNetwork.makeElement(assetType: lowVoltageAssetType, globalID: globalID)

Utility element properties

A terminal is required when a UtilityElement that supports more than one terminal A terminal represents logical ports, entries, or exit locations on a single device or junction object within a utility network. Each port can flow in or out. Each device can contain many terminals, all of which can be interconnected. Learn more is used in a trace and optional when used to get associations An association is a relationship between two elements that is reflected in a utility network topology. Learn more . Terminals impact traces A trace is an action that analyzes the paths in a utility network and returns features based on connectivity or traversability from the specified starting points. Learn more and connectivity associations.

if let terminalsCount = element.assetType.terminalConfiguration?.terminals.count,
terminalsCount > 1 {
element.terminal = element.assetType.terminalConfiguration?.terminals.first
}

If the feature A feature is a single record, also known as a row, that represents a real-world entity. It typically contains a geometry (point, multipoint, polyline, or polygon) and attributes but it can also contain just attributes. Learn more 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.

if element.networkSource.kind == UtilityNetworkSource.Kind.edge {
var line = feature.geometry as? Polyline
if let polyline = line,
polyline.hasZ {
// If the polyline has a Z value, remove it.
let line2 = GeometryEngine.makeGeometry(from: polyline, z: nil)
line = line2
}
if mapPoint.spatialReference != nil,
let polyline = line,
polyline.spatialReference != mapPoint.spatialReference,
let projectedLine = GeometryEngine.project(polyline, into: mapPoint.spatialReference!) {
// Projects the line to the map point's spatial reference, if not already equivalent.
line = projectedLine
}
guard let polyline = line else { return }
// Calculates and sets the fraction of a tap location along the line.
let percentAlong = GeometryEngine.polyline(polyline, fractionalLengthClosestTo: mapPoint, tolerance: .nan)
if !percentAlong.isNaN {
element.fractionAlongEdge = percentAlong
}
}