You can display and share a complete utility network using a web map or mobile geodatabase. You should include at most one feature layer for every feature table in the utility network.
You can also create a map programmatically, making use of subtype feature layers (known as subtype group layers in ArcGIS Pro and in the web map). Subtype feature layers allow you to set symbology and other layer properties on a per-subtype basis. Utility networks make extensive use of subtypes (referred to as asset groups within a utility network). For example, a device feature table from an electric utility network would include subtypes for fuses, switches, transformers, and other kinds of equipment. For more information, see the Display subtype feature layer sample.
You can use display filters to show and hide features inside containers, replicating the functionality available in ArcGIS Pro to show or hide containment association content. You can also use display filters to ensure that critical network features are returned in a trace result even if they are removed from the view to simplify the display. For more information, see display filters in feature layers.
Access a utility network
Utility networks are implemented as network controller datasets. These datasets contain a network's feature tables along with the network's domains, sources, tiers, assets, terminals, rules, and associations. A utility network is accessible from a feature service geodatabase or a mobile geodatabase.
You can display and share a complete utility network with a user via a web map if the map includes one feature layer for every network source.
A UtilityNetwork
object in Native Maps SDKs can be created from an online or an offline source.
These sources provide access to the topological network in the utility network. For example, you can provide a map that contains a subset of the feature layers for a specific workflow; any tracing is performed using the full topological network provided by the feature service. To add additional utility network layers, you can create them from the individual network sources as required. You can also access a utility network and run a trace completely without a map, just provide the feature service URL when you create the utility network or load a utility network from a mobile geodatabase.
Utility Network version 2 and later is supported. This is provided from ArcGIS Pro 2.2 and later. For details see utility network upgrade history.
Access a utility network from an online source
Online sources include a URL to a feature service or a feature service portal item. Maps from a web map portal item authored in ArcGIS Pro version 2.6 or higher may also include utility networks.
When using either a URL to a feature service or a portal item as source, create and load a service geodatabase with tables that are used to create the layers on the map. Then create a utility network with the same source and map.
val serviceGeodatabase = ServiceGeodatabase(featureServiceUrl)
coroutineScope.launch {
serviceGeodatabase.load().getOrElse {
return@launch showError("Error loading service geodatabase: ${it.message}")
}
map = ArcGISMap(BasemapStyle.ArcGISNavigationNight)
val serviceFeatureTable = serviceGeodatabase.getTable(layerId = 0)
?: return@launch showError("No feature table found.")
val featureLayer = FeatureLayer.createWithFeatureTable(serviceFeatureTable)
map.operationalLayers.add(featureLayer)
utilityNetwork = UtilityNetwork(
uri = featureServiceUrl,
map = map
)
When using a web map portal item URL as source, get the utility network from a loaded map.
map = ArcGISMap(uri = webMapURL)
map.load()
utilityNetwork = map.utilityNetworks.firstOrNull() ?: return showError("Web map contains no utility networks.")
Branch-versioning
When a utility network is based on a ServiceGeodatabase
that points to an ArcGIS Enterprise Feature Service (version 10.6 or higher) with branch versioning enabled, you can view, edit, and perform a trace on specific versions. Read more about Branch versioning in the ArcGIS Pro documentation and see the Use branch versioned data topic in this guide for more information.
A service geodatabase can be created in a persistent or transient session. Using a web map or creating a service geodatabase without a session type by default creates a service geodatabase in a transient session. A service geodatabase in a persistent session acquires a shared lock from the server during load which may be upgraded to an exclusive lock during an edit to allow multiple simultaneous viewers or a single editor. A service geodatabase in a transient session will not hold a lock to allow concurrent viewers and editors.
val serviceGeodatabase = ServiceGeodatabase(url = featureServiceUrl, sessionType = FeatureServiceSessionType.Persistent)
To create and switch to the new version ...
val versionParameters = ServiceVersionParameters()
versionParameters.access = VersionAccess.Private
versionParameters.name = "MyVersionName"
val serviceGeodatabase = utilityNetwork.serviceGeodatabase ?: return showError("Failed to get service geodatabase from the utility network.")
val serviceVersionInfo = serviceGeodatabase.createVersion(versionParameters).getOrElse { error ->
return showError("Failed to create a geodatabase branch version: $error.")
}
val versionName = serviceVersionInfo.name
serviceGeodatabase.switchVersion(versionName = versionName)
To get versions accessible to the logged-in user and switch to a specific version ...
val serviceGeodatabase = utilityNetwork.serviceGeodatabase ?: return showError("Failed to get service geodatabase from the utility network.")
val versionInfos = serviceGeodatabase.fetchVersions().getOrElse { error ->
return showError("Failed to fetch versions for service geodatabase.")
}
val foundVersionInfo = versionInfos.find { serviceVersionInfo ->
serviceVersionInfo.name == "userName.MyVersionName"
} ?: return showError("Could not find service version info.")
serviceGeodatabase.switchVersion(versionName = foundVersionInfo.name)
Access a utility network from an offline source
Offline sources include path to a mobile geodatabase file with a *.geodatabase
extension or a web map containing a UtilityNetwork
that has been taken offline.
A mobile geodatabase source can be one of the following:
-
a stand-alone mobile geodatabase that is exported from ArcGIS Pro 2.7 or higher
-
a sync-enabled mobile geodatabase that is generated from ArcGIS Enterprise Feature Service 10.9 or higher using a
GeodatabaseSyncTask
orOfflineMapSyncTask
.
When using a mobile geodatabase, create and load a geodatabase whose tables are used to create the layers and utility networks on the map.
val geodatabase = Geodatabase(path = pathToGeodatabase)
val map = ArcGISMap(BasemapStyle.ArcGISStreetsNight)
val featureTable = geodatabase.getFeatureTable(serviceLayerId = 0) ?: return showError("Failed to create a feature layer from the feature table.")
val featureLayer = FeatureLayer.createWithFeatureTable(featureTable)
map.operationalLayers.add(featureLayer)
val utilityNetwork = geodatabase.utilityNetworks.firstOrNull() ?: return showError("Geodatabase contains no utility networks.")
map.utilityNetworks.add(utilityNetwork)
Load the utility network
The utility network follows the loadable pattern.
Loading the utility network loads the entire utility network schema (information about the datasets that participate in the network). Once loaded, your app can navigate this network schema to discover the domain networks it contains and any further details about the network. The utility network's definition includes the capabilities supported by the utility network object, such as whether tracing and/or querying associations are supported.
utilityNetwork.load().onFailure { return showError("Failed to load the utility network.") }
val utilityNetworkDefinition = utilityNetwork.definition ?: return showError("Failed to get the definition of the utility network.")
if (utilityNetworkDefinition.capabilities.supportsTrace) {
val traceResults = utilityNetwork.trace(utilityTraceParameters).getOrElse { error ->
return showError("Failed to get utility trace elements: $error")
}
}
if (utilityNetworkDefinition.capabilities.supportsQueryAssociations) {
val associations = utilityNetwork.getAssociations(utilityElement).getOrElse { error ->
return showError("Failed to get associations for the utility element: $error")
}
}