You can display and share a complete utility network
You can also create a map programmatically, making use of subtype feature layers
You can use display filters to show and hide features
Access a utility network
Utility networks are implemented as network controller datasets. These datasets contain a network's feature tables
You can display and share a complete utility network with a user via a web map
A UtilityNetwork object in Native Maps SDKs can be created from an online or an offline
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
Utility Network version 2 and later is supported. This is provided from ArcGIS Pro
Access a utility network from an online source
Online sources include a URL to a feature service
When using either a URL to a feature service or a portal item
// Create a new map based on the basemap style of ArcGISStreetsNight.
m_map = new Map(BasemapStyle::ArcGISStreetsNight, this);
// Create a service geodatabase from a feature service url.
ServiceGeodatabase* serviceGeodatabase = new ServiceGeodatabase(featureServiceUrl, this);
// When the service geodatabse is done loading, continue processing.
connect(serviceGeodatabase, &ServiceGeodatabase::doneLoading, this, [this,
serviceGeodatabase] (const Error& error)
{
// Provide error handling.
if (!error.isEmpty())
{
qDebug() << "Error:" << error.message();
return;
}
// Obtain the service feature tables from the service geodatabase.
ServiceFeatureTable* serviceFeatureTable = serviceGeodatabase->table(0);
// Create a feature layer from the service feature table.
FeatureLayer* featureLayer = new FeatureLayer(serviceFeatureTable, this);
// Add the feature layer to the operational layers of the map.
m_map->operationalLayers()->append(featureLayer);
// Create a utility network from the service geodatabase.
UtilityNetwork* utilityNetwork = new UtilityNetwork(serviceGeodatabase, this);
// Provide some feedback.
qDebug() << utilityNetwork->name();
});
// Load the service geodatabase.
serviceGeodatabase->load();
When using a web map portal item
// Create a new map from the web map url.
Map* map = new Map(webmapUrl, this);
// When the map is done loading, continue processing.
connect(map, &Map::doneLoading, this, [map](const Error& error)
{
// Provide error handling.
if (!error.isEmpty())
{
qDebug() << "Error:" << error.message();
return;
}
// If the maps utility network list model is not empty, continue processing.
if(!map->utilityNetworks()->isEmpty())
{
// Get the utility network from the maps first utility network list model.
UtilityNetwork* utilityNetwork = map->utilityNetworks()->first();
qDebug() << utilityNetwork->name();
}
});
// Load the map.
map->load();
Branch-versioning
When a utility network is based on a ServiceGeodatabase that points to an ArcGIS Enterprise
A service geodatabase
// Create a service geodatabase based on a feature service url and the
// feature service session type of Persistent.
ServiceGeodatabase* serviceGeodatabase = new ServiceGeodatabase(featureServiceUrl,
FeatureServiceSessionType::Persistent, this);
To create and switch to the new version ...
// Create a new service version parameters, set the access and name.
ServiceVersionParameters* serviceVersionParameters = new ServiceVersionParameters(this);
serviceVersionParameters->setAccess(VersionAccess::Private);
serviceVersionParameters->setName("MyVersionName");
// Get the service geodatabase from the utility network.
ServiceGeodatabase* serviceGeodatabase = utilityNetwork->serviceGeodatabase();
// Get the service version info from the service geodatabase via the create
// version async method (uses QFuture).
serviceGeodatabase->createVersionAsync(serviceVersionParameters,this).then(this,
[serviceGeodatabase] (ServiceVersionInfo* serviceVersionInfo)
{
// Switch to a specific service geodatabase via the service version info name.
QFuture<void> returnVal = serviceGeodatabase->switchVersionAsync(serviceVersionInfo->name());
});
To get versions accessible to the logged-in user and switch to a specific version ...
// Create a new service geodatabase from the utility netowrk service geodatabase.
ServiceGeodatabase* serviceGeodatabase = utilityNetwork->serviceGeodatabase();
// Get the QList of service version info objects from the service geodatabase via
// the fetch versions async method (uses QFuture).
serviceGeodatabase->fetchVersionsAsync(this).then(this, [serviceGeodatabase]
(const QList<ServiceVersionInfo*> serviceVersionInfos)
{
// Get the service version info from the first one in the list of service version info objects.
ServiceVersionInfo* serviceVersionInfo = serviceVersionInfos.first();
// Test of the service version info name matches a specific string.
if(serviceVersionInfo->name() == "userName.MyVersionName")
{
// Switch the service geodatabase to a specific version based on the service version info name.
QFuture<void> returnVal = serviceGeodatabase->switchVersionAsync(serviceVersionInfo->name());
}
});
Access a utility network from an offline source
Offline*.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
A mobile geodatabase (.geodatabase) is a spatial data storage format in a single file on disk that can store, query, and manage spatial and nonspatial data. In applications built with the ArcGIS Maps SDKs for Native Apps, mobile geodatabases can be used in offline workflows when taking maps and features offline from services or in desktop-based scenarios as standalone mobile geodatabases from ArcGIS Pro. that is exported from ArcGIS ProArcGIS Pro is a professional desktop GIS application that can explore, visualize, analyze, and manage 2D and 3D data. 2.7 or higher -
a sync-enabled mobile geodatabase that is generated from ArcGIS Enterprise
ArcGIS Enterprise is a GIS mapping, analytics, data hosting, and content management product that can be hosted on-premise or in a cloud infrastructure. It includes software, applications, tools, APIs, and services for users and developers. Feature Service 10.9 or higher using aGeodatabaseSyncTaskorOfflineMapSyncTask.
When using a mobile geodatabase, create and load a geodatabase
// Create a new map based on the basemap style of ArcGISStreetsNight.
Map* map = new Map(BasemapStyle::ArcGISStreetsNight, this);
// Create a feature layer from the geodatabase's first geodatabase feature table.
FeatureLayer* featureLayer = new FeatureLayer(geodatabase->geodatabaseFeatureTable(0), this);
// Add the feature layer to the operational layers of the map.
map->operationalLayers()->append(featureLayer);
// Test if the geodatabase utility network is not empty, continue processing.
if (!geodatabase->utilityNetworks().isEmpty())
{
// Add the first utility network in the geodatabase to the maps utility network list model.
const QList<UtilityNetwork*> utilityNetworks = geodatabase->utilityNetworks();
map->utilityNetworks()->append(utilityNetworks.first());
// Get the utility network from the first maps utility networks list model entry.
UtilityNetwork* utilityNetwork = map->utilityNetworks()->first();
// Provide some feedback.
qDebug() << utilityNetwork->name();
}
Load the utility network
The utility network follows the loadable
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
// Create and load the utility network.
UtilityNetwork* utilityNetwork = new UtilityNetwork(serviceGeodatabase, this);
utilityNetwork->load();