Updated: Sep 13, 2022
Load the Web Map
First we select the web map instead of loading a raw feature service. This will trigger two things:
We check if the web map is pointing to a feature service and make sure that the feature service has a utility network. Only then we create a utilitynetwork object by passing the feature service URL and the token. The Utilitynetwork class is a helper class that does all the heavy lifting of querying various end points to pull the necessary meta data to open a utility network.
Query and highlight subnetwork
Having access to the full definition of the utility network, we can list properties like domain networks, tiers, network attributes etc.
We first populate all the domains network in the utility network in a drop-down list. When the user selects a domain network all the tiers that are available in that domain network will be populated. The user selects a tier, we call a rest endpoint to query the subnetworks table to filter out all subnetworks that belong to that tier. The subnetworks table is a table published as a layer in the feature service. To get access to that layer we need to ask the utility network for its subnetwork layer id so we can query for subnetworks. The utilitynetwork helper class has that method that returns the subnetline layer which is in the utility network definition. We then query that layer only returning geometry. Finally, we create a graphic of the returned geometry and add it to the map view making sure to clear all existing graphics to end up with multiple graphics on the map.
The trace method is a REST end-point on the Utility Network Server extension. It takes many parameters, starting points, barriers, trace type, trace definition and many related to the version and moment which are optional. We will do Subnetwork Trace.
To run a subnetwork trace, the REST trace method is expecting the subnetwork name along with the domain name and tier name. We will require subnetwork definition which is the “boundary” of a subnetwork, e.g. in the electric network would be to stop the trace when it finds an open device.The subnetwork definition is part of the tier the subnetwork belongs to. To retrieve that we need to pull that of the tier.
We now need to send a POST request with all the information including the token, leaving the version, sessionid and moment blank, the trace will be executed on the latest representation of the Default branch.
The trace results by default returns an array of features, however it only returns these attributes “SourceID”, “GlobalID” and the “ObjectID”. There is no Layerid. The SourceID is an internal representation of the feature classes that acts as sources for the utility network. We will have to map the SourceID to the LayerId. Utilitynetwork helper class has a nice method namely getLayerIdfromSourceId that does just that.
Then we will recollect all results grouped by layerId and objectIds and make few queries to retrieve the geometries of those features so that we can draw graphics, to highlight the results on the map.
Above is the graphic result of selected features from the trace result.
This work highlights the power of the services oriented architecture nature of the Utility Network Management extension.
Contact us at agilytics or write to us to firstname.lastname@example.org for more details.
Note: Source code is available on request.