Editing Utility Networks

Editing Features

Editing features is simple and can be done via the FeatureService.applyEdits(). Editing Utility Network features will generate dirty areas. To learn more about editing features using FeatureService.applyEdits(). Please visit the Feature Service guide doc to learn more about editing features.

Introduction to Associations

Editing Associations are performed with the applyEdits () method on the Feature Service class. Editing Associations has been simplified as of 4.29 with the introduction of the generateAddAssociation and generateDeleteAssociations on the UtilityNetwork class.

How to Edit Associations

The example below demonstrates how to edit Associations.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  // Instantiating a UtilityNetwork instance using layerUrl
  const utilityNetwork = new UtilityNetwork({
        layerUrl: "https://hostName.com/server/rest/services/Test/FeatureServer/17";
      });
  await utilityNetwork.load();

  const association = new Association({
      globalId: "{88355CB3-B011-4715-BB90-047B8C7ABF48}",
      fromNetworkElement: new NetworkElement({
        globalId: "{09B7A0F9-811D-4CCF-95A9-D1995D44C631}",
        networkSourceId: 8,
        terminalId: 1,
        assetGroupCode: 1,
        assetTypeCode: 1,
      }),
      toNetworkElement: new NetworkElement({
        globalId: "{86DD4700-4D1B-4872-93CD-68783F7996B6}",
        networkSourceId: 10,
        terminalId: 1,
        assetGroupCode: 2,
        assetTypeCode: 2,
      }),
      associationType: "attachment",
    });

  const canAdd = await utilityNetwork.canAddAssociation(association); // Will check rules table to verify if given associations are valid
  const generatedAddAssociation = await utilityNetwork.generateAddAssociations([association]);
  const generatedDeleteAssociation = await utilityNetwork.generateDeleteAssociations([association]);

  if(association)
      //Adding new Association
      await featureService.applyEdits(
              [generatedAddAssociation],
              {
                gdbVersion: "name.demo",
                globalIdUsed: false,
                honorSequenceOfEdits: false,
                usePreviousEditMoment: false,
                returnServiceEditsInSourceSR: false
              }
            );
  await featureService.applyEdits(
          [generatedDeleteAssociation],
          {
            gdbVersion: "name.demo",
            globalIdUsed: true, // Must be true when deleting Associations via generateDeleteAssociations
            honorSequenceOfEdits: false,
            usePreviousEditMoment: false,
            returnServiceEditsInSourceSR: false
          }
        );

Before calling generateAddAssociations the canAddAssociation routine can validate whether the given Associations are valid.

Introduction to Validating Network Topology

Validating the network topology for a utility network's maintains consistency between feature editing space and network topology space. Validating a network topology may include all or a subset of the dirty areas present in the network. Validation of network topology is supported synchronously and asynchronously. Validate should be done after edits are made, and before network tracing. In editing workflows for a utility network, the validation of the network topology is also treated as an edit operation. As portions of the network are edited or modified, they become out of date in the network topology and are marked with dirty areas. Dirty areas serve as an indicator that the content you see on the map does not match what is stored in the network topology. It is important to keep the network topology updated for analytic events; this is done by validating the network topology.

When to Validate ?

You should validate network topology regularly to ensure that your network is functioning properly. Whenever an edit is made on a Utility Network a dirty area will form. Validating should be done after editing, and before network tracing to ensure network consistency. A dirty area represents a portion of the network that has been modified or updated but has not yet been synchronized with the rest of the network. Validating a network's topology will remove dirty areas and update the network topology so that it matches the values in the features. For dirty areas to be visible, the dirty area layer must be added to the map. The URL for this layer can be obtained from UtilityNetwork.networkSystemLayers.dirtyAreasTableUrl.

Validate Network Topology Using the Utility Network Class

Validating Topology using the Utility Network class may be done either synchronously or asynchronously. Synchronous is faster, although it is also subject to timeouts if performed on a very large number of features. The asynchronous option is slower, but it won't time out. Therefore when validating a large number of features async is advised. For example, validating network topology synchronously:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  // Instantiating a UtilityNetwork instance using layerUrl
  const utilityNetwork = new UtilityNetwork({
        layerUrl: "https://hostName.com/server/rest/services/Test/FeatureServer/17";
      });
  await utilityNetwork.load();

  const extent = new Extent({
        xmin: 470789.0888,
        ymin: 3597733.2051,
        xmax: 531454.2759999996,
        ymax: 3639864.802100001,
        spatialReference: { wkid: 26911, latestWkid: 26911 }
   });

  await utilityNetwork.validateTopology({ validateArea: extent });

For example, validating network topology asynchronously

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  // Instantiating a UtilityNetwork instance using layerUrl
  const utilityNetwork = new UtilityNetwork({
        layerUrl: "https://hostName.com/server/rest/services/Test/FeatureServer/17"
      });
  await utilityNetwork.load();

  const extent = new Extent({
        xmin: 470789.0888,
        ymin: 3597733.2051,
        xmax: 531454.2759999996,
        ymax: 3639864.802100001,
        spatialReference: { wkid: 26911, latestWkid: 26911 }
});

  await utilityNetwork.submitTopologyJob({ validateArea: extent });

Validate Network Topology Using the Validate Network Topology Widget

If you want your web app to include a user interface for validate network topology, the JavaScript API provides a widget that can be easily added to your application. Simply configure the widget and its ready to go. For example:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  // How to use the UtilityNetworkValidateTopology widget
  view.when(async () => {
    // load all the layers in the map
    await view.map.loadAll();

    // if the map does not contain a utility network layer return
    if(!(view.map.utilityNetworks.items.length > 0)) {
      return;
    }

    utilityNetwork = view.map.utilityNetworks.getItemAt(0);
    await utilityNetwork.load();

    // function to add the dirty areas layer to the map
    addDirtyAreasLayer();

    // initialize the UtilityNetworkValidateTopology widget
    const unValidateTopology = new UtilityNetworkValidateTopology({
      view,
      utilityNetwork: utilityNetwork
    });

    view.ui.add(unValidateTopology, "top-left");
  });

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.