public UtilityNetwork GetUtilityNetwork()
Public Function GetUtilityNetwork() As UtilityNetwork
Return Value
The utility network associated with the layer.
public UtilityNetwork GetUtilityNetwork()
Public Function GetUtilityNetwork() As UtilityNetwork
Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
ArcGIS.Core.Data.Exceptions.GeodatabaseUtilityNetworkException | Could not open the utility network. |
// This routine obtains a utility network from a FeatureLayer, SubtypeGroupLayer, or UtilityNetworkLayer public static UtilityNetwork GetUtilityNetworkFromLayer(Layer layer) { UtilityNetwork utilityNetwork = null; if (layer is UtilityNetworkLayer) { UtilityNetworkLayer utilityNetworkLayer = layer as UtilityNetworkLayer; utilityNetwork = utilityNetworkLayer.GetUtilityNetwork(); } else if (layer is SubtypeGroupLayer) { CompositeLayer compositeLayer = layer as CompositeLayer; utilityNetwork = GetUtilityNetworkFromLayer(compositeLayer.Layers.First()); } else if (layer is FeatureLayer) { FeatureLayer featureLayer = layer as FeatureLayer; using (FeatureClass featureClass = featureLayer.GetFeatureClass()) { if (featureClass.IsControllerDatasetSupported()) { IReadOnlyList<Dataset> controllerDatasets = new List<Dataset>(); controllerDatasets = featureClass.GetControllerDatasets(); foreach (Dataset controllerDataset in controllerDatasets) { if (controllerDataset is UtilityNetwork) { utilityNetwork = controllerDataset as UtilityNetwork; } else { controllerDataset.Dispose(); } } } } } return utilityNetwork; }
Target Platforms: Windows 11, Windows 10