Starting with version 100.11, you can take certain utility network information offline. Associations, which are used to describe containment, structural attachment, and connection between features with non-coincident geometry, can be queried and displayed with offline data. Simple edits can also be made to utility network features while offline and synchronized back to ArcGIS Enterprise.
The following code takes a web map offline that contains a utility network. The utility network tables are automatically synced with a map when a utility network is detected within.
// Create a new offline map task.
m_offlineMapTask = new OfflineMapTask(map, this);
// Get the generate offline map parameters from the offline map task via the
// create default generate offline map parameters async method (QFuture).
m_offlineMapTask->createDefaultGenerateOfflineMapParametersAsync(envelope).then(this, [this]
(const GenerateOfflineMapParameters& defaultParams)
{
// Create a modifiable version of the generate offline map parameters.
GenerateOfflineMapParameters params = defaultParams;
// Set the include basemap as false for the modifiable version of the generate offline map parameters.
params.setIncludeBasemap(false);
// Define the path to download the geodatabase to.
const QString gdbPath = m_tempPath.path() + "/OfflineMapWithUtilityNetwork";
// Get the generate offline map job from the offline map task.
GenerateOfflineMapJob* m_generateOfflineMapJob = m_offlineMapTask->
generateOfflineMap(params, gdbPath);
// Test if we have a valid (non null) generate offline map job.
if (m_generateOfflineMapJob)
{
// When the generate offline map job's status has changed, continue processing.
connect(m_generateOfflineMapJob, &Job::statusChanged, this,
&UtilityNetworks::generateOfflineMapJobStatusChanged);
// Start the enerate offline map job.
m_generateGdbJob->start();
}
});
}
// Function to execute when the generate offline map job status has changed.
void UtilityNetworks::generateOfflineMapJobStatusChanged()
{
// Get the job status.
switch (m_generateOfflineMapJob->jobStatus())
{
case JobStatus::Succeeded: // Job status succeeded.
{
// Get the resulting geodatabase from the generate offline map job.
GenerateOfflineMapResult* offlineMapResult = m_generateOfflineMapJob->result();
// Get the offline map from the offline map result.
Map* mapOffline = offlineMapResult->offlineMap();
// Get the utility network list model from the offline map.
UtilityNetworkListModel* utilityNetworkListModel = mapOffline->utilityNetworks();
// Only continue if we have a valid offline map result or the utility network is empty.
if (!offlineMapResult || utilityNetworkListModel->isEmpty())
return;
// Get and load the utility network.
m_utilityNetwork = utilityNetworkListModel->first();
// Load the utility network.
m_utilityNetwork->load();
break;
}
The following code generates a sync-enabled mobile geodatabase from a feature service. By default, only feature data are included unless you specify a sync mode for the utility network.
// Create a new GeodatabaseSyncTask to download the mobile geodatabase.
m_geodatabaseSyncTask = new GeodatabaseSyncTask(featureServerUrl, this);
// Get the generate geodatabase parameters from the geodatabase sync task via the
// create default generate geodatabase parameters async method (QFuture).
m_geodatabaseSyncTask->createDefaultGenerateGeodatabaseParametersAsync(envelope).then(this,
[this](const GenerateGeodatabaseParameters& defaultParams)
{
// Create an modifiable version of the generate geodatabase parameters.
GenerateGeodatabaseParameters params = defaultParams;
// Set utility network system tables to be synchronized.
params.setUtilityNetworkSyncMode(UtilityNetworkSyncMode::SyncSystemTables);
// Define the path to download the geodatabase to.
const QString gdbPath = m_tempPath.path() + "/offline_utility_network.geodatabase";
// Create a generate geodatabase job to generate a geodatabase.
m_generateGdbJob = m_geodatabaseSyncTask->generateGeodatabase(params, gdbPath);
// Test of the generate geodatabase job is not null.
if (m_generateGdbJob)
{
// When the generate geodatabase job's status has changed, continue processing.
connect(m_generateGdbJob, &Job::statusChanged, this,
&UtilityNetworks::generateGeodatabaseJobStatusChanged);
// Start the generate geodatabase job.
m_generateGdbJob->start();
}
});
}
// Function to execute when the generate geodatabase job status has changed.
void UtilityNetworks::generateGeodatabaseJobStatusChanged()
{
// Get the job status.
switch (m_generateGdbJob->jobStatus())
{
case JobStatus::Succeeded: // Job status succeeded.
{
// Get the resulting geodatabase from this job.
Geodatabase* gdb = m_generateGdbJob->result();
// Test if the geodatabase is not null or the utility network is empty.
if (!gdb || gdb->utilityNetworks().isEmpty())
return;
// Get the QList of utility networks from the geodatabase.
const QList<UtilityNetwork*> utilityNetworks = gdb->utilityNetworks();
// Get the first utility network from the QList of utility networks.
m_utilityNetwork = utilityNetworks.first();
// Load the utility network.
m_utilityNetwork->load();
break;
}
For more information about offline workflows using ArcGIS Maps SDKs for Native Apps, see the Offline maps, scenes, and data topic.