An array of analysis
This utility element may be created from a feature or asset type
Utility element from a feature
You may query for a specific feature using any of its fields or geometry or interactively identify a feature in a map viewGeoElement list immediately under IdentifyLayerResult when part of a FeatureLayer or from SublayerResults when part of a SubtypeFeatureLayer.
var query = new QueryParameters() { WhereClause = "GlobalId like '{D353C10C-E617-4618-BDD0-B48EDB822D07}'" };
var queryResult = await table.QueryFeaturesAsync(query);
var feature = queryResult.FirstOrDefault() as ArcGISFeature;
var identifyLayerResults = await MainMapView.IdentifyLayersAsync(e.Position, 5, false);
ArcGISFeature? feature = null;
foreach (var layerResult in identifyLayerResults)
{
if (layerResult.LayerContent is SubtypeFeatureLayer)
{
foreach (var subLayerResult in layerResult.SublayerResults)
{
if (feature is not null)
break;
foreach (ArcGISFeature geoElement in subLayerResult.GeoElements)
{
if (feature is not null)
break;
feature = geoElement;
}
}
}
else if (layerResult.LayerContent is FeatureLayer)
{
foreach (ArcGISFeature geoElement in layerResult.GeoElements)
{
if (feature is not null)
break;
feature = geoElement;
}
}
}
await feature.LoadAsync();
var element = _utilityNetwork.CreateElement(feature);
Utility element from an asset type
An asset type
var assetType = otherElement.AssetType;
var element = _utilityNetwork.CreateElement(assetType, globalId);
var tableName = feature.FeatureTable?.TableName;
var networkSource = _utilityNetwork.Definition?.GetNetworkSource(tableName);
var subtypeName = feature.GetFeatureSubtype()?.Name;
var assetGroup = networkSource?.GetAssetGroup(subtypeName);
var assetTypeCode = (int)feature.Attributes["ASSETTYPE"];
assetType = assetGroup?.AssetTypes?.FirstOrDefault(t => t.Code == assetTypeCode);
networkSource = _utilityNetwork.Definition?.GetNetworkSource("Electric Distribution Device");
assetGroup = networkSource?.GetAssetGroup("Service Point");
assetType = assetGroup?.GetAssetType("Single Phase Low Voltage Meter");
element = _utilityNetwork.CreateElement(assetType, globalId);
Utility element properties
A terminal is required when a UtilityElement that supports more than one terminal
if (element.AssetType.TerminalConfiguration?.Terminals.Count > 1)
element.Terminal = element.AssetType.TerminalConfiguration?.Terminals?.FirstOrDefault();
If the feature
Use UtilityElement.FractionAlongEdge to define the location of the point along the line.
The following example uses the GeometryEngine to get the fraction of a tap location along the line.
if (element.NetworkSource?.SourceType == UtilityNetworkSourceType.Edge && feature.Geometry is Polyline line)
{
if (line.HasZ && GeometryEngine.RemoveZ(line) is Polyline line2)
{
line = line2;
}
if (mapPoint.SpatialReference != null &&
line.SpatialReference != mapPoint.SpatialReference &&
GeometryEngine.Project(line, mapPoint.SpatialReference) is Polyline projectedLine)
{
line = projectedLine;
}
var percentAlong = GeometryEngine.FractionAlong(line, mapPoint, double.NaN);
if (!double.IsNaN(percentAlong))
{
element.FractionAlongEdge = percentAlong;
}
}