This document is archived and information here might be outdated.  Recommended version.


INetworkClass.FieldToWeightMapping Property (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (GeoDatabase)  

INetworkClass.FieldToWeightMapping Property

The specified field to Weight mapping for the logical network.

[Visual Basic .NET]
Public Function get_FieldToWeightMapping ( _
    ByVal FieldIndex As Integer _
) As Integer
[C#]
public int get_FieldToWeightMapping (
    int FieldIndex
);
[C++]
HRESULT get_FieldToWeightMapping(
  long FieldIndex,
  System.Int32* WeightID
);
[C++]

Parameters FieldIndex [in]
FieldIndex is a parameter of type long WeightID [out, retval]
WeightID is a parameter of type long*

Product Availability

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

Remarks

The FieldToWeightMapping property will return the index of the network weight to which a field in the network class is mapped in the logical network. You can then use the INetSchema::Weight property to return the INetWeight interface on that particular network weight. If the field has no weight associated with it, FieldToWeightMapping returns a -1.

[C#]

The following code prints the name of the weight assoiated with each field in a network class.

// Use the INetSchema interface to get network weights.
IGeometricNetwork geometricNetwork=networkClass.GeometricNetwork;
INetwork network=(INetwork)geometricNetwork.Network;
INetSchema netSchema=(INetSchema)network;
// For each field in the network class, print its weight associations.
IFields fields=networkClass.Fields;
for (int i=0; i < fields.FieldCount; i++)
{
IField field=fields.get_Field(i);
int weightIndex=networkClass.get_FieldToWeightMapping(i);
if (weightIndex != -1)
{
INetWeight weight=netSchema.get_Weight(weightIndex);
Console.WriteLine("{0} maps to {1}", field.Name, weight.WeightName);
}
else
{
Console.WriteLine("{0} maps to nothing", field.Name);
}
}
[Visual Basic .NET]

The following code prints the name of the weight assoiated with each field in a network class.

' Use the INetSchema interface to get network weights.
Dim geometricNetwork As IGeometricNetwork=networkClass.GeometricNetwork
Dim network As INetwork=CType(geometricNetwork.Network, INetwork)
Dim netSchema As INetSchema=CType(network, INetSchema)
' For each field in the network class, print its weight associations.
Dim fields As IFields=networkClass.Fields
Dim i As Integer
For i=0 To fields.FieldCount - 1
Dim field As IField=fields.Field(i)
Dim weightIndex As Integer=networkClass.FieldToWeightMapping(i)
If weightIndex <> -1 Then
Dim weight As INetWeight=netSchema.Weight(weightIndex)
Console.WriteLine("{0} maps to {1}", field.Name, weight.WeightName)
Else
Console.WriteLine("{0} maps to nothing", field.Name)
End If
Next

See Also

INetworkClass Interface | IGeometricNetwork Interface | INetwork Interface | INetWeight Interface