Supported with: ArcGIS Engine, ArcGIS Desktop, ArcGIS Server
Library dependencies: System, SystemUI, Geometry, Display, Server, Output, GeoDatabase, GISClient, DataSourcesFile, DataSourcesGDB, DataSourcesOleDB, DataSourcesRaster, GeoDatabaseDistributed, Carto, NetworkAnalyst, Location
Additional library information: Contents, Object Model Diagram
This content is also available in versions that specifically target .NET and Java developers. Click on the appropriate link to view either version.
.NET overview of the NetworkAnalysis assembly
Java overview of the NetworkAnalysis package
The NetworkAnalysis library provides objects for populating a geodatabase with network data and objects to analyze the network when it is loaded in the geodatabase. In addition, the library contains helper objects used for converting between the geometric network features and the logical network elements.
Developers can utilize this library to support custom network tracing. The library is meant to work with utility networks such as gas lines, electricity supply lines, and so on.
The objects that implement this functionality are grouped into a number of library subsystems. These library subsystems are:
The NetworkLoader coclass allows you to specify input parameters for the name and type of network, the feature classes to be included, the feature classes to be used as sources and sinks, and the weights you wish to employ. All of these parameters are specified up front through the object, and then the LoadNetwork method is executed to generate the geometric network and its logical network.
When you execute the LoadNetwork method, a logical network is generated based on the feature classes you specify. An enabled/disabled field is added within the table for each feature class to keep track of whether flow can go through each individual feature. There is also a domain created with the values of "enabled" and "disabled". This domain is automatically assigned to the created field within each feature class.
The INetworkLoader and INetworkLoader2 interfaces let you set the parameters to use in building a geometric network out of a set of feature classes within the same dataset. Use these interfaces when you want to define and generate your geometric network.
The INetworkLoaderProps interface allows you to see the default field names that will be added to each feature class and the name of the domain. In addition, default field and domain names can be returned for the ancillary role (feature classes that contain sources or sinks).
There are two solver objects contained in this library. Both objects are used together to perform network analysis. The NetSolver object prepares the solver environment with the necessary weights and filters, while the TraceFlowSolver object sets the flags and performs the analysis through the network.
The NetSolver object sets the table for the trace methods found in the TraceFlowSolver class. Through this object, you can specify the network you are working on, disable entire network classes, specify individual barriers, and define weights. The derived TraceFlowSolver class can then be used to run a trace on the defined problem.
The INetSolver interface specifies barriers and disabled classes. This interface is key when you need to limit your traces based on the exclusion of entire classes or individual elements. This interface offers three different ways to set barriers for the purpose of limiting traces.
The DisableElementClass method stops traces at every instance of the specified class. For example, if you have a gas pipe that has burst and you need to identify all valves to shutoff, then you would use this method to set barriers at every valve in the network.
The ElementBarriers property lets you specify an INetElementBarriers object that contains individual elements to use as barriers. These could be barriers composed of closed street segments, bridges that are out, or individual electric switches that have been opened for some reason.
The SelectionSetBarriers property is similar to the ElementBarriers property. It allows you to specify an ISelectionSetBarriers object to use as a barrier in your trace-solving routine. SelectionSetBarriers are meant to be barriers based on a selected set of elements, such as 8-inch pipes and six-lane highways.
Here is some sample code for using the ElementBarriers property to set barriers based on a set of identified elements.
Sub SetEdgeBarrier(pNetwork As INetwork, pFeatClass As IFeatureClass, lEdgeOID1 As Long, lEdgeOID2 As Long) 'Create the NetElementBarriers object Dim pNetEdgeBarriers As INetElementBarriers, lOIDs(0 To 1) As Long Set pNetEdgeBarriers = New NetElementBarriers lOIDs(0) = lEdgeOID1 lOIDs(1) = lEdgeOID2 Set pNetEdgeBarriers.Network = pNetwork pNetEdgeBarriers.ElementType = esriETEdge pNetEdgeBarriers.SetBarriers pFeatClass.FeatureClassID, 2, lOIDs(0) 'Pass in the first element of the array 'Set the edge barrier in the TraceFlowSolver Dim pTraceFlowSolver As ITraceFlowSolver, pNetSolver As INetSolver Set pTraceFlowSolver = New TraceFlowSolver Set pNetSolver = pTraceFlowSolver Set pNetSolver.SourceNetwork = pNetwork Set pNetSolver.ElementBarriers(esriETEdge) = pNetEdgeBarriers End Sub
Here is some sample code for using the ElementBarriers property to set barriers based on a set of identified elements.
Sub SetEdgeBarrier(network As INetwork, featClass As IFeatureClass, edgeOID1 As Integer, edgeOID2 As Integer) 'Create the NetElementBarriers object Dim netEdgeBarriers As INetElementBarriersGEN = New NetElementBarriers Dim oidArray(0 To 1) As Integer oidArray(0) = edgeOID1 oidArray(1) = edgeOID2 netEdgeBarriers.Network = network netEdgeBarriers.ElementType = esriETEdge netEdgeBarriers.SetBarriers(featClass.FeatureClassID, oidArray) 'Set the edge barrier in the TraceFlowSolver Dim traceFlowSolver As ITraceFlowSolverGEN = New TraceFlowSolver Dim netSolver As INetSolver = CType(traceFlowSolver, INetSolver) netSolver.SourceNetwork = network netSolver.ElementBarriers(esriETEdge) = netEdgeBarriers End Sub
Here is some sample code for using the ElementBarriers property to set barriers based on a set of identified elements.
void SetEdgeBarrier(INetwork network, IFeatureClass featClass, int edgeOID1, int edgeOID2)
{
//Create the NetElementBarriers object
INetElementBarriersGEN netEdgeBarriers = new NetElementBarriersClass() as INetElementBarriersGEN;
int[] oidArray = new int[2];
oidArray[0] = edgeOID1;
oidArray[1] = edgeOID2;
netEdgeBarriers.Network = network;
netEdgeBarriers.ElementType = esriETEdge;
netEdgeBarriers.SetBarriers(featClass.FeatureClassID, oidArray);
//Set the edge barrier in the TraceFlowSolver
ITraceFlowSolverGEN traceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN;
INetSolver netSolver = traceFlowSolver as INetSolver;
netSolver.SourceNetwork = network;
netSolver.ElementBarriers(esriETEdge) = netEdgeBarriers;
}
The INetSolverWeights interface specifies the weights to use during trace-solving procedures. For a description of how weights are used, see the NetWeight coclass documentation. This interface allows you to specify junction and edge weights and also set the filters to be used in conjunction with the weights. The filters specify the attribute values or ranges to use or not use when tracing. For instance, a cathodic protection trace might be done by tracing on steel pipe, so the weight filter would indicate to trace only on the value representing steel pipe.
Filter weights (FromToEdgeFilterWeight, ToFromEdgeFilterWeight, and JunctionFilterWeight) are used to explicitly specify the type of feature on which you do or do not want to trace.
FromToEdgeFilterWeight, FromToEdgeWeight, ToFromEdgeFilterWeight, and ToFromEdgeWeight get their from- and to-direction based on the digitized direction of the edge.
Here is some sample code for setting filter weights on edges and junctions. The edge weight is called "Material", and the filter is being set to not trace on values of 1. The junction weight is called "Fitting_Type", and the filter is being set to not trace on values of 8.
Sub SetFilterWeights(pNetwork As INetwork)
Dim pNetSolverWeights As INetSolverWeights
Dim pWeight As INetWeight, pSchema As INetSchema
Dim lRange(0) As Long
'Establish the trace flow solver
Dim pTraceFlowSolver As ITraceFlowSolver
Set pTraceFlowSolver = New TraceFlowSolver
Dim pNetSolver As INetSolver
Set pNetSolver = pTraceFlowSolver
Set pNetSolver.SourceNetwork = pNetwork
'Add the weights
Set pSchema = pNetwork
Set pNetSolverWeights = pTraceFlowSolver
Set pWeight = pSchema.WeightByName("Material")
Set pNetSolverWeights.FromToEdgeFilterWeight = pWeight
Set pNetSolverWeights.ToFromEdgeFilterWeight = pWeight
pNetSolverWeights.SetFilterType esriETEdge, esriWFRange, True
lRange(0) = 1
pNetSolverWeights.SetFilterRanges esriETEdge, 1, lRange(0), lRange(0)
Set pWeight = pSchema.WeightByName("Fitting_Type")
Set pNetSolverWeights.JunctionFilterWeight = pWeight
pNetSolverWeights.SetFilterType esriETJunction, esriWFRange, True
lRange(0) = 8
pNetSolverWeights.SetFilterRanges esriETJunction, 1, lRange(0), lRange(0)
End Sub
Here is some sample code for setting filter weights on edges and junctions. The edge weight is called "Material", and the filter is being set to not trace on values of 1. The junction weight is called "Fitting_Type", and the filter is being set to not trace on values of 8.
Sub SetFilterWeights(network As INetwork)
Dim range(0) As Integer
'Establish the trace flow solver
Dim traceFlowSolver As ITraceFlowSolverGEN = New TraceFlowSolver
Dim netSolver As INetSolver = CType(traceFlowSolver, INetSolver)
netSolver.SourceNetwork = network
'Add the weights
Dim netSchema As INetSchema = CType(network, INetSchema)
Dim netSolverWeights As INetSolverWeightsGEN = CType(netSolverWeights, INetSolverWeightsGEN)
Dim netWeight As INetWeight = netSchema.WeightByName("Material")
netSolverWeights.FromToEdgeFilterWeight = netWeight
netSolverWeights.ToFromEdgeFilterWeight = netWeight
netSolverWeights.SetFilterType(esriETEdge, esriWFRange, True)
range(0) = 1
netSolverWeights.SetFilterRanges(esriETEdge, range, range)
netWeight = netSchema.WeightByName("Fitting_Type")
netSolverWeights.JunctionFilterWeight = netWeight
netSolverWeights.SetFilterType(esriETJunction, esriWFRange, True)
range(0) = 8
netSolverWeights.SetFilterRanges(esriETJunction, range, range)
End Sub
Here is some sample code for setting filter weights on edges and junctions. The edge weight is called "Material", and the filter is being set to not trace on values of 1. The junction weight is called "Fitting_Type", and the filter is being set to not trace on values of 8.
void SetFilterWeights(INetwork network)
{
int[] range = new int[1];
//Establish the trace flow solver
ITraceFlowSolverGEN traceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN;
INetSolver netSolver = traceFlowSolver as INetSolver;
netSolver.SourceNetwork = network;
//Add the weights
INetSchema netSchema = network as INetSchema;
INetSolverWeightsGEN netSolverWeights = netSolverWeights as INetSolverWeightsGEN;
INetWeight netWeight = netSchema.WeightByName("Material");
netSolverWeights.FromToEdgeFilterWeight = netWeight;
netSolverWeights.ToFromEdgeFilterWeight = netWeight;
netSolverWeights.SetFilterType(esriETEdge, esriWFRange, true);
range[0] = 1;
netSolverWeights.SetFilterRanges(esriETEdge, range, range);
netWeight = netSchema.WeightByName("Fitting_Type");
netSolverWeights.JunctionFilterWeight = netWeight;
netSolverWeights.SetFilterType(esriETJunction, esriWFRange, true);
range[0] = 8;
netSolverWeights.SetFilterRanges(esriETJunction, range, range);
}
The TraceFlowSolver object contains a set of traces developed by ESRI for use with custom code. You also have the option of generating your own trace routines by using the ForwardStar object.

The ITraceFlowSolver interface lets you specify junction and edge origins and then execute one of the trace methods. These trace methods should allow you to perform the majority of required tracing tasks; traces not included with these interfaces need to be constructed via the ForwardStar object.

The ITraceFlowSolver2 interface adds more trace solvers to the TraceFlowSolver object. It can be used in a similar way as the ITraceFlowSolver interface.
Many of the traces require that flow direction has been established on the network. You can set flow direction through the IUtilityNetwork interface.
There are four basic trace algorithms that can be used to solve a variety of trace-flow problems. These methods are used in the Utility Network Analyst toolbar to create the nine trace tasks available there, and they can also be used by the developer to create an unlimited number of new tasks.
The following samples illustrate the use of the solver objects.
The NetFlag abstract class has two classes that are derived from it: EdgeFlag and JunctionFlag. The purpose of the class is to specify the starting points (flags) of traces and path-finding routines. When a flag is created, it is necessary to specify whether that flag is on an edge or a junction. The PutEdgeOrigins and PutJunctionOrigins methods on ITraceFlowSolver include the flags in the current trace.
The INetFlag interface is the only interface on the NetFlag object. This interface allows set and retrieve access on the individual properties of the element being used as a flag. Use this interface to specify the user class and ID of the element.
UserSubID specifies the index of the particular element you want to use as a flag within a complex junction or edge feature.
An EdgeFlag object is a type of NetFlag object. The EdgeFlag object specifies the starting point of a trace or path algorithm. As the name implies, the flag (or starting point) must be on an edge feature. This object creates a flag that is associated with an edge feature.
The IEdgeFlag interface is the only interface on the EdgeFlag object. This interface provides access to the flag properties unique for an edge. Use this interface to specify the position of the flag on the edge and whether or not the flag is to be used for flow in both directions along the edge. The Position property specifies the percentage location of the flag down the edge beginning at the "from" point.
A JunctionFlag object is a type of NetFlag object. The JunctionFlag object specifies the starting point (flag) of a trace or path algorithm. As the name implies, the flag must be on a junction feature.
The IJunctionFlag interface is the only interface on the JunctionFlag object. This interface has no properties or methods but serves as a way to identify what type of flag you have. For instance, if an object supports IJunctionFlag, then you know you have a JunctionFlag object.
The following samples illustrate the use of the NetFlag objects.
The FlagDisplay abstract class supports two coclasses, JunctionFlagDisplay and EdgeFlagDisplay, for the tracking of flags set through the Utility Network Analyst toolbar. The purpose of the class is to monitor flags set through the toolbar and make sure they are correctly displayed when the map is redrawn. Flags are used by the network toolbar as starting points for traces.
The IFlagDisplay interface provides access to the properties of flags set through the Utility Network Analyst toolbar. These properties include the feature class, ID, and SubID (if a complex network feature) of the feature the flag was placed on, as well as the symbol used to draw the flag. The SubID must be specified, even for noncomplex network features. You can look up any network element’s ID by calling INetElements::QueryIDs and passing in its EID.
The ClientClassID and ClientFID properties are specifically for developer use. These properties are not used by the core ArcGIS software in any way.
Geometry returns a point object representing the location of the flag.
The JunctionFlagDisplay coclass is a type of FlagDisplay that supports flags placed on junction elements through the network toolbar. At any time, there can be zero or more JunctionFlagDisplay objects associated with the toolbar.
The IJunctionFlagDisplay interface has no properties or methods but can be used to determine if the FlagDisplay object is a JunctionFlagDisplay object.
The EdgeFlagDisplay coclass is a type of FlagDisplay that supports flags placed on edge elements through the Utility Network Analyst toolbar. At any time, there can be zero or more EdgeFlagDisplay objects associated with the toolbar.
The IEdgeFlagDisplay interface allows the developer to determine if the FlagDisplay object is of type EdgeFlagDisplay. The only property on the interface (Percentage) returns the position of the flag on the edge measured as a percentage from the digitized "from" end of the feature.
The following code demonstrates how to take the edge flags set within the network toolbar and pass them to a TraceFlowSolver object.
Sub FlagDisplay(pFlags As INetworkAnalysisExtFlags, pTraceSolver As ITraceFlowSolver)
Dim pEFlags() As IEdgeFlag, pEdgeFlagDisplay As IFlagDisplay
Dim pEdgeFlag As INetFlag, i As Long
ReDim pEFlags(pFlags.EdgeFlagCount - 1)
For i = 0 To pFlags.EdgeFlagCount - 1
Set pEdgeFlagDisplay = pFlags.EdgeFlag(i)
Set pEdgeFlag = New EdgeFlag
pEdgeFlag.UserID = pEdgeFlagDisplay.FID
pEdgeFlag.UserClassID = pEdgeFlagDisplay.FeatureClassID
pEdgeFlag.Label = "Edge"
Set pEFlags(i) = pEdgeFlag
Next i
Dim lCount As Long
lCount = pFlags.EdgeFlagCount
pTraceSolver.PutEdgeOrigins lCount, pEFlags(0)
End Sub
The following code demonstrates how to take the edge flags set within the network toolbar and pass them to a TraceFlowSolver object.
Sub FlagDisplay(flags As INetworkAnalysisExtFlags, traceSolver As ITraceFlowSolverGEN)
Dim edgeFlags() As IEdgeFlag, edgeFlagDisplay As IFlagDisplay
Dim edgeFlag As INetFlag, i As Integer
ReDim edgeFlags(0 To flags.EdgeFlagCount - 1)
For i = 0 To flags.EdgeFlagCount - 1
edgeFlagDisplay = flags.EdgeFlag(i)
edgeFlag = New EdgeFlag
edgeFlag.UserID = edgeFlagDisplay.FID
edgeFlag.UserClassID = edgeFlagDisplay.FeatureClassID
edgeFlag.Label = "Edge"
edgeFlags(i) = edgeFlag
Next i
traceSolver.PutEdgeOrigins(edgeFlags)
End Sub
The following code demonstrates how to take the edge flags set within the network toolbar and pass them to a TraceFlowSolver object.
void FlagDisplay(INetworkAnalysisExtFlags flags, ITraceFlowSolverGEN traceSolver)
{
IEdgeFlag[] edgeFlags = new IEdgeFlag[flags.EdgeFlagCount];
IFlagDisplay edgeFlagDisplay;
INetFlag edgeFlag;
for (int i = 0; i < flags.EdgeFlagCount; i++)
{
edgeFlagDisplay = flags.EdgeFlag(i);
edgeFlag = New EdgeFlagClass() as INetFlag;
edgeFlag.UserID = edgeFlagDisplay.FID;
edgeFlag.UserClassID = edgeFlagDisplay.FeatureClassID;
edgeFlag.Label = "Edge";
edgeFlags[i] = edgeFlag;
}
traceSolver.PutEdgeOrigins(edgeFlags);
}
The following samples illustrate the use of the FlagDisplay objects.
There are two barrier objects contained in this library. These objects specify to the NetSolver object through which network elements the trace and path tasks cannot pass.
There are two ways the NetElementBarriers coclass can be created. You can either create the object directly and set the barriers manually, or you can generate the object through INetworkAnalysisExtBarriers::CreateElementBarriers. When this object is generated through CreateElementBarriers, the resulting barrier elements are based on what was set by the user through the toolbar.
The INetElementBarriers interface is used to set the type of element (edge or junction) contained within the class and to set the barriers.
SetBarriers specifies which network features are to be used as barriers. If a network feature is a complex edge, then all elements of that feature will be added to the barrier.
The INetElementBarriers2 interface was added at ArcGIS 8.1 to allow barrier elements to be added without it acting on the entire complex feature.
SetBarriersByEID allows barriers to be specified by their element EID. This option saves the developer from having to perform a query on the element to determine the feature class ID and feature ID.
The SelectionSetBarriers coclass is similar to NetElementBarriers but can contain both junction and edge elements. When creating your own custom trace tool, you can create your own SelectionSetBarriers object or generate one through INetworkAnalysisExtBarriers::CreateSelectionBarriers. The resulting class can then be applied during the analysis process through the NetSolver object.
SelectionSetBarriers offers an additional advantage over NetElementBarriers in that the Not method can be used to specify that elements not within the class will act as barriers.
The ISelectionSetBarriers interface allows new barriers to be added to the set through the Add method but also offers the Not method to specify that elements not currently within the set (instead of what is within the set) will serve as barriers.
The following sample illustrates the use of the barrier objects.
The network analysis helper objects assist in the conversion between the domain of network elements and the domain of geometry and features. For example, the PointToEID object can convert a map coordinate to a flag position along the network, while the EIDHelper object can convert the numerous EIDs returned by the trace solver to geometry that can be displayed on the map.
The PointToEID object finds the nearest network element to a given point in a geometric network.
The IPointToEID interface is used for finding the element ID (EID) and point location of the nearest edge or junction element in a geometric network to a given point. In the case of finding the nearest edge element, the position of the point along the edge is also returned. This position is measured as a percentage from the digitized "from" end of the edge.
The result EID will be from the specified geometric network and will correspond to a feature from one of the layers in the specified source map.
The SnapTolerance is in the map units of the specified SourceMap.
The following code can be used to place a junction flag on the nearest junction feature to the given (x,y) map coordinate.
Sub PlaceJunctionFlag(x As Double, y As Double, pMap As IMap, _
pNetworkAnalysisExt As INetworkAnalysisExt, pFlagSymbol As ISymbol)
Dim pPoint As IPoint
Dim pPointToEID As IPointToEID
Dim lEID As Long
Dim pGeometry As IGeometry
Dim pNetElements As INetElements
Dim lFCID As Long, lFID As Long, lSubID As Long
Dim pJunctionFlagDisplay As IJunctionFlagDisplay
Dim pFlagDisplay As IFlagDisplay
Dim pNetworkAnalysisExtFlags As INetworkAnalysisExtFlags
Set pPoint = New Point
pPoint.X = x
pPoint.Y = y
Set pPointToEID = New PointToEID
With pPointToEID
Set .GeometricNetwork = pNetworkAnalysisExt.CurrentNetwork
Set .SourceMap = pMap
.SnapTolerance = 10 'set a snap tolerance of 10 map units
.GetNearestJunction pPoint, lEID, pGeometry
End With
Set pNetElements = pNetworkAnalysisExt.CurrentNetwork.Network
pNetElements.QueryIDs lEID, esriETJunction, lFCID, lFID, lSubID
Set pJunctionFlagDisplay = New JunctionFlagDisplay
Set pFlagDisplay = pJunctionFlagDisplay
With pFlagDisplay
.FeatureClassID = lFCID
.FID = lFID
.SubID = lSubID
Set .Geometry = pGeometry
Set .Symbol = pFlagSymbol
End With
Set pNetworkAnalysisExtFlags = pNetworkAnalysisExt
pNetworkAnalysisExtFlags.AddJunctionFlag pJunctionFlagDisplay
End Sub
The following code can be used to place a junction flag on the nearest junction feature to the given (x,y) map coordinate.
Sub PlaceJunctionFlag(x As Double, y As Double, map As IMap, _
networkAnalysisExt As INetworkAnalysisExt, flagSymbol As ISymbol)
Dim point As IPoint = New Point
point.X = x
point.Y = y
Dim EID As Integer
Dim outPoint As IPoint
Dim pointToEID As IPointToEID = New PointToEID
With pointToEID
.GeometricNetwork = networkAnalysisExt.CurrentNetwork
.SourceMap = map
.SnapTolerance = 10 'set a snap tolerance of 10 map units
.GetNearestJunction(point, EID, outPoint)
End With
Dim netElements As INetElements = CType(networkAnalysisExt.CurrentNetwork.Network, INetElements)
Dim FCID As Integer, FID As Integer, subID As Integer
pNetElements.QueryIDs(EID, esriETJunction, FCID, FID, subID)
Dim junctionFlagDisplay As IJunctionFlagDisplay = New JunctionFlagDisplay
Dim flagDisplay As IFlagDisplay = CType(junctionFlagDisplay, IFlagDisplay)
With flagDisplay
.FeatureClassID = FCID
.FID = FID
.SubID = subID
.Geometry = CType(outPoint, IGeometry)
.Symbol = flagSymbol
End With
Dim networkAnalysisExtFlags As INetworkAnalysisExtFlags = CType(networkAnalysisExt, INetworkAnalysisExtFlags)
networkAnalysisExtFlags.AddJunctionFlag(junctionFlagDisplay)
End Sub
The following code can be used to place a junction flag on the nearest junction feature to the given (x,y) map coordinate.
void PlaceJunctionFlag(double x, double y, IMap map,
INetworkAnalysisExt networkAnalysisExt, ISymbol flagSymbol)
{
IPoint point = new PointClass() as IPoint;
point.X = x;
point.Y = y;
int EID;
IPoint outPoint;
IPointToEID pointToEID = new PointToEIDClass() as IPointToEID;
pointToEID.GeometricNetwork = networkAnalysisExt.CurrentNetwork;
pointToEID.SourceMap = map;
pointToEID.SnapTolerance = 10; //set a snap tolerance of 10 map units
pointToEID.GetNearestJunction(point, out EID, out outPoint);
INetElements netElements = networkAnalysisExt.CurrentNetwork.Network as INetElements;
int FCID, FID, subID;
pNetElements.QueryIDs(EID, esriETJunction, out FCID, out FID, out subID);
IJunctionFlagDisplay junctionFlagDisplay = new JunctionFlagDisplayClass() as IJunctionFlagDisplay;
IFlagDisplay flagDisplay = junctionFlagDisplay as IFlagDisplay;
flagDisplay.FeatureClassID = FCID;
flagDisplay.FID = FID;
flagDisplay.SubID = subID;
flagDisplay.Geometry = outPoint as IGeometry;
flagDisplay.Symbol = flagSymbol;
INetworkAnalysisExtFlags networkAnalysisExtFlags = networkAnalysisExt as INetworkAnalysisExtFlags;
networkAnalysisExtFlags.AddJunctionFlag(junctionFlagDisplay);
}
The EIDHelper coclass allows you to quickly query information on the features corresponding to a given set of network element IDs (EIDs). This object is important because it provides the ability to efficiently query the geometry and field values for these features and return them in a single cursor.
As an example of when this object would be used, consider an upstream trace operation. The trace operation is performed on the network with results being the elements that are traversed. The EIDHelper coclass is necessary to take this set of elements and determine the actual features that were traversed. The features could then be listed as part of a report or simply highlighted.
The IEIDHelper interface lets you set the parameters to use in retrieving the geometry and features. All of the settings are specified upfront through this interface, and then the CreateEnumEIDInfo method is executed to generate a cursor containing the geometry and/or feature objects. You have the option of returning only geometry objects or only feature objects or both.
Feature objects that are returned in the cursor are meant only for querying attribute values from the features and not for editing the features. These feature objects will only contain those fields specified using the AddField method. For optimization purposes, if no calls are made to AddField before calling the CreateEnumEIDInfo method, the feature objects returned will only contain the OID and Shape fields.
Use the DisplayEnvelope property to limit the number of feature and/or geometry objects returned in the cursor. Only those objects whose geometry lies within the specified DisplayEnvelope are returned. If the DisplayEnvelope is set to Nothing, then all features and/or geometries corresponding to the EIDs are returned, regardless of their spatial position.
PartialComplex specifies whether only the subgeometries of the individual elements of a complex feature are returned or not. When this property is False, the geometry for the entire complex feature is returned regardless of whether each element is in the input set of EIDs or not (assuming at least one element of the complex feature is in the input set).
The following samples illustrate the use of the helper objects.