ArcObjects Library Reference (NetworkAnalysis)  

INetworkLoaderProps Interface

Provides access to memebers that return the default names of fields and domains used by the network loader.

Product Availability

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

When To Use

Use the INetworkLoaderProps interface to get the correct names for the fields required by INetworkLoader to build a geometric network.

Members

Description
Read-only property DefaultAncillaryRoleDomain Default ancillary role domain name.
Read-only property DefaultAncillaryRoleField Default ancillary role field name.
Read-only property DefaultEnabledDomain Default enabled domain name.
Read-only property DefaultEnabledField Default enabled field name.

CoClasses that implement INetworkLoaderProps

CoClasses and Classes Description
NetworkLoader A container for specifying the parameters for building a geometric network.

Remarks

When you are building a network, certain fields are required in the feature classes in which you are building your network. For example, each feature class must have an enabled/disabled field. If you specify sources/sinks, a field for the ancillary role is required. The NetworkLoader requires you to tell it what these field names are.

The default field names for these fields are accessible via the INetworkLoaderProps interface. These default field names are reserved words in the Geodatabase. It is strongly recommended that you use these default field names when calling PutAncillaryRole and PutEnabledDisabledFieldName on the INetworkLoaderinterface.

Even if you are using the default field names, if these fields already exist in your feature classes, it is best to check that they are of the correct domain and subtype. Use the CheckAncillaryRoleField and CheckEnabledDisabledField methods on the INetworkLoader2 interface to check these fields before Putting them on the NetworkLoader object.

[C#]

The following code demonstrates using the default field name for the ancillary role field and checking its validity if it already exists. It assumes the NetworkLoader object is referenced by networkLoader2, the the target feature dataset is referenced by featureDataset, and the name of the feature class to have an ancillary role field is referenced by featureClassName:

INetworkLoaderProps networkLoaderProps = networkLoader2 as INetworkLoaderProps;
string defARField = networkLoaderProps.DefaultAncillaryRoleField;
IFeatureClassContainer featureClassContainer = featureDataset as IFeatureClassContainer;
IFeatureClass featureClass = featureClassContainer.ClassByName(featureClassName);
//if the field already exists, check the field
if (featureClass.FindField(defARField) >= 0)
if (networkLoader2.CheckAncillaryRoleField(featureClassName, fieldName) != esriNLFCValid)
{
Console.WriteLine(fieldName & " is not valid as an ancillary role field.");
return; //field is invalid -- do not call PutAncillaryRole
}

//otherwise, this field is a valid ancillary role field
networkLoader2.PutAncillaryRole(featureClassName, esriNCARSourceSink, fieldName);
[Visual Basic .NET]

The following code demonstrates using the default field name for the ancillary role field and checking its validity if it already exists. It assumes the NetworkLoader object is referenced by networkLoader2, the the target feature dataset is referenced by featureDataset, and the name of the feature class to have an ancillary role field is referenced by featureClassName:

Dim networkLoaderProps As INetworkLoaderProps = CType(networkLoader2, INetworkLoaderProps)
Dim defARField As String = networkLoaderProps.DefaultAncillaryRoleField
Dim featureClassContainer As IFeatureClassContainer = CType(featureDataset, IFeatureClassContainer)
Dim featureClass As IFeatureClass = featureClassContainer.ClassByName(featureClassName)
'if the field already exists, check the field
If featureClass.FindField(defARField) >= 0 Then
  If networkLoader2.CheckAncillaryRoleField(featureClassName, fieldName) <> esriNLFCValid Then
    Console.WriteLine(fieldName & " is not valid as an ancillary role field.")
    Exit Sub 'field is invalid -- do not call PutAncillaryRole
  End If
End If

'otherwise, this field is a valid ancillary role field
networkLoader2.PutAncillaryRole(featureClassName, esriNCARSourceSink, fieldName)

See Also

INetworkLoaderProps Interface | INetworkLoaderProgress Interface | INetworkLoader Interface