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 getSublayerResults() when part of a SubtypeFeatureLayer.
// Create the element from an ArcGIS feature.UtilityElement utilityElement = utilityNetwork.createElement(arcGISFeature, null);Utility element from an asset type
An asset type
Utility element properties
A terminal is required when a UtilityElement that supports more than one terminal
UtilityTerminalConfiguration terminalConfiguration = utilityElement.getAssetType().getTerminalConfiguration();
if (terminalConfiguration != null) { List<UtilityTerminal> utilityTerminals = terminalConfiguration.getTerminals();
if (!utilityTerminals.isEmpty()) { UtilityTerminal utilityTerminal = utilityTerminals.getFirst();
utilityElement.setTerminal(utilityTerminal); }}If the feature
Use UtilityElement.setFractionAlongEdge() 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.
// Determine how far the starting point is located along the linePolyline polyline = (Polyline) GeometryEngine.removeZ(geometry);
double fraction = GeometryEngine.fractionAlong(polyline, point, -1.0);
if (!Double.isNaN(fraction)) { utilityElement.setFractionAlongEdge(fraction);}