ArcObjects Library Reference (NetworkAnalysis)  

INetworkLoader.PutAncillaryRole Method

Specifies the ancillary role attribute field for the specified feature class.

[Visual Basic .NET]
Public Sub PutAncillaryRole ( _
    ByVal featureClassName As String, _
    ByVal ancillaryRole As esriNetworkClassAncillaryRole, _
    ByVal ancillaryRoleFieldName As String _
)
[C#]
public void PutAncillaryRole (
    string featureClassName,
    esriNetworkClassAncillaryRole ancillaryRole,
    string ancillaryRoleFieldName
);
[C++]
HRESULT PutAncillaryRole(
  BSTR featureClassName,
  esriNetworkClassAncillaryRole ancillaryRole,
  BSTR ancillaryRoleFieldName
);
[C++]

Parameters

featureClassName [in]   featureClassName is a parameter of type BSTR ancillaryRole [in]

  ancillaryRole is a parameter of type esriNetworkClassAncillaryRole

ancillaryRoleFieldName [in]   ancillaryRoleFieldName is a parameter of type BSTR

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

A feature class that you specify as having an ancillary role means its features can either be sources or sinks and it will determine flow in your network. The feature classes you want to be built as having an ancillary role must be point feature classes. Multiple feature classes in the network can have ancillary roles. To do this, simply call the PutAncillaryRole method for each feature class to have ancillary roles.
 
The field name you specify will contain the ancillary role attribute for this feature class. It is strongly recommended to use the default name for the ancillary role field. The default name for the ancillary role field can be obtained from the DefaultAncillaryRoleField property on the INetworkLoaderProps interface. If you specify an existing field to use as the ancillary role field, it is best to check that this field is of the correct type and domain can become an ancillary role field. You can check this by calling the CheckAncillaryRoleField method. If the field specified does not exist, then the NetworkLoader will automatically add it to the feature class when it builds the network, populating all values in this field with the value 0.
[C#]

The following code demonstrates using the default ancillary role field name and checking the ancillary role field before calling PutAncillaryRole:

INetworkLoaderProps networkLoaderProps = networkLoader2 as INetworkLoaderProps;
string defARFld = networkLoaderProps.DefaultAncillaryRoleField;
esriNetworkLoaderFieldCheck ckFld = networkLoader2.CheckAncillaryRoleField("FeatureClassName", defARFld);
switch (ckFld)
{
case esriNLFCValid:
case esriNLFCNotFound:
pNetworkLoader2.PutAncillaryRole("FeatureClassName", esriNCARSourceSink, sDefARFld);
break;
default:
Console.WriteLine("The field " + defARFld + " could not be used as an ancillary role field.");
return;
break;
}
[Visual Basic .NET]

The following code demonstrates using the default ancillary role field name and checking the ancillary role field before calling PutAncillaryRole:

Dim networkLoaderProps As INetworkLoaderProps = CType(networkLoader2, INetworkLoaderProps)
Dim defARFld As String = networkLoaderProps.DefaultAncillaryRoleField
Dim ckFld As esriNetworkLoaderFieldCheck = networkLoader2.CheckAncillaryRoleField("FeatureClassName", defARFld)
Select Case ckFld
Case esriNLFCValid, esriNLFCNotFound
pNetworkLoader2.PutAncillaryRole("FeatureClassName", esriNCARSourceSink, sDefARFld)
Case Else
Console.WriteLine("The field " & defARFld & " could not be used as an ancillary role field.")
Exit Sub
End Select

See Also

INetworkLoader Interface

.NET Related Topics

Creating geometric networks within a geodatabase |