Associations An association is a relationship between two elements that is reflected in a utility network topology. Learn more enable the modeling of connectivity, containment, and structure attachment An attachment is a file, such as a photograph (for example, a .png file) or a document, that is associated with individual features in a geodatabase or feature layer. Learn more between non-spatial and non-coincident network features. The following table describes the types of relationships between two utility network elements:

AssociationDescriptionGeometry supported
ConnectivityModels the connectivity between two junctions that don’t have geometric coincidence (are not in the same x, y and z location). A transformer may be connected to a fuse, for example.Yes
Structural attachmentModels equipment attached to structures. A transformer bank may be attached to a pole, for example.Yes
ContainmentModels assets that contain other assets. A vault may contain valves and pipes, for example.No

Utility network associations

// Get the elements associated (by containment) with a specified utility element.
val utilityAssociations = utilityNetwork.getAssociations(
element = utilityElement,
type = UtilityAssociationType.Containment
).getOrElse { error ->
return showError("Error getting associations: ${error.message}")
}
// Iterate all associations for this element.
utilityAssociations.forEach { utilityAssociation ->
// Get the first ("from") and second ("to") elements in the association.
val fromElement = utilityAssociation.fromElement
val toElement = utilityAssociation.toElement
}

You can also provide an envelope to find all valid associations within the specified extent.

The following example creates a new graphics overlay to display all associations within the map extent using a unique symbol A symbol defines the properties used to display a geometry or text. Learn more for each association type.

// Get the current viewpoint's extent.
val extent = currentViewpoint.targetGeometry.extent
// Create symbols for structural attachment and connectivity associations.
val attachmentSymbol = SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.green, 5F)
val connectivitySymbol = SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.red, 5F)
// Create a unique value renderer for the associations and apply it to the graphics overlay.
val attachmentValue = UniqueValue(
description = "Attachment",
symbol = attachmentSymbol,
values = listOf(UtilityAssociationType.Attachment.javaClass.simpleName)
)
val connectivityValue = UniqueValue(
description = "Connectivity",
symbol = connectivitySymbol,
values = listOf(UtilityAssociationType.Connectivity.javaClass.simpleName)
)
graphicsOverlay.renderer = UniqueValueRenderer(
fieldNames = listOf("AssociationType"),
uniqueValues = listOf(attachmentValue, connectivityValue)
)
// Get all of the associations in the current extent.
val utilityAssociations = utilityNetwork.getAssociations(extent).getOrElse { error ->
return showError("Error getting associations: ${error.message}")
}
utilityAssociations.forEach { utilityAssociation ->
// If it's not a containment relationship, add a graphic for the association.
if (utilityAssociation.associationType != UtilityAssociationType.Containment) {
val graphic = Graphic(utilityAssociation.geometry).apply {
attributes["GlobalId"] = utilityAssociation.globalId
attributes["AssociationType"] = utilityAssociation.associationType.javaClass.simpleName
}
graphicsOverlay.graphics.add(graphic)
}
}

Specifying 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 will return all its associations unless the utility element’s 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 has been set, which limits the connectivity associations returned.

Specifying an extent will return all its connectivity or structural attachment associations with geometry. The geometry value (polyline) represents the connection relationship between a from element and a to element. You can use the geometry to visualize the association as a graphic A graphic is a visual element composed of a geometry, symbol, and attributes that is displayed on a map or scene. Learn more in the map.