[VB.NET]
' Create a new empty data element for a buildable network dataset.
Dim deND As IDENetworkDataset = New DENetworkDataset
deND.Buildable = True
' Open the feature dataset and CType to the IGeoDataset interface.
Dim gdbWSF As IWorkspaceFactory = New FileGDBWorkspaceFactory
Dim gdbFWS As IFeatureWorkspace = CType(gdbWSF.OpenFromFile("C:\Program Files\ArcGIS\DeveloperKit\SamplesNET\data\CreateNetworkDataset\Paris.gdb", 0), IFeatureWorkspace)
Dim fdsGDS As IGeoDataset = CType(gdbFWS.OpenFeatureDataset("RoadNetwork"), IGeoDataset)
' Copy the feature dataset's extent and spatial reference to the network dataset data element.
Dim deGDS As IDEGeoDataset = CType(deND, IDEGeoDataset)
deGDS.Extent = fdsGDS.Extent
deGDS.SpatialReference = fdsGDS.SpatialReference
' Specify the name of the network dataset.
Dim dataElement As IDataElement = CType(deND, IDataElement)
dataElement.Name = "ParisNet"
[C#]
// Create a new empty data element for a buildable network dataset.
IDENetworkDataset deNetworkDataset = new DENetworkDatasetClass();
deNetworkDataset.Buildable = true;
// Open the feature dataset and cast to the IGeoDataset interface.
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactory();
IWorkspace workspace = workspaceFactory.OpenFromFile(@
"C:\Program Files\ArcGIS\DeveloperKit\SamplesNET\data\CreateNetworkDataset\Paris.gdb", 0);
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
IFeatureDataset featureDataset = featureWorkspace.OpenFeatureDataset("RoadNetwork");
IGeoDataset geoDataset = (IGeoDataset)featureDataset;
// Copy the feature dataset's extent and spatial reference to the network dataset data element.
IDEGeoDataset deGeoDataset = (IDEGeoDataset)deNetworkDataset;
deGeoDataset.Extent = geoDataset.Extent;
deGeoDataset.SpatialReference = geoDataset.SpatialReference;
// Specify the name of the network dataset.
IDataElement dataElement = (IDataElement)deNetworkDataset;
dataElement.Name = "ParisNet";
[VB.NET]
' Create a new EdgeFeatureSource object and point it to the Streets feature class.
Dim edgeNetSource As INetworkSource = New EdgeFeatureSource
edgeNetSource.Name = "Streets"
edgeNetSource.ElementType = esriNETEdge
' Set the edge feature source's connectivity settings.
Dim edgeFS As IEdgeFeatureSource = CType(edgeNetSource, IEdgeFeatureSource)
With edgeFS
.UsesSubtypes = True
.SubtypeConnectivityGroup(1) = 1
.SubtypeConnectivityPolicy(1) = esriNECPEndVertex
.SubtypeConnectivityGroup(2) = 1
.SubtypeConnectivityPolicy(2) = esriNECPEndVertex
.SubtypeConnectivityGroup(3) = 1
.SubtypeConnectivityPolicy(3) = esriNECPAnyVertex
End With
[C#]
// Create a new EdgeFeatureSource object and point it to the Streets feature class.
INetworkSource edgeNetworkSource = new EdgeFeatureSourceClass();
edgeNetworkSource.Name = "Streets";
edgeNetworkSource.ElementType = esriNetworkElementType.esriNETEdge;
// Set the edge feature source's connectivity settings.
IEdgeFeatureSource edgeFeatureSource = (IEdgeFeatureSource)edgeNetworkSource;
edgeFeatureSource.UsesSubtypes = true;
edgeFeatureSource.set_SubtypeConnectivityGroup(1, 1);
edgeFeatureSource.set_SubtypeConnectivityPolicy(1,
esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex);
edgeFeatureSource.set_SubtypeConnectivityGroup(2, 1);
edgeFeatureSource.set_SubtypeConnectivityPolicy(2,
esriNetworkEdgeConnectivityPolicy.esriNECPEndVertex);
edgeFeatureSource.set_SubtypeConnectivityGroup(3, 1);
edgeFeatureSource.set_SubtypeConnectivityPolicy(3,
esriNetworkEdgeConnectivityPolicy.esriNECPAnyVertex);
[VB.NET]
' Create a StreetNameFields object and populate its settings.
Dim snf As IStreetNameFields = New StreetNameFields
With snf
.Priority = 1 'Priority 1 indicates the primary street name.
.StreetNameFieldName = "FULL_NAME"
End With
' Add the StreetNameFields object to a new NetworkSourceDirections object,
' then add it to the EdgeFeatureSource created earlier.
Dim nsd As INetworkSourceDirections = New NetworkSourceDirections
Dim snfArray As IArray = New ESRI.ArcGIS.esriSystem.Array
snfArray.Add(snf)
nsd.StreetNameFields = snfArray
edgeNetSource.NetworkSourceDirections = nsd
[C#]
// Create a StreetNameFields object and populate its settings.
IStreetNameFields streetNameFields = new StreetNameFieldsClass();
streetNameFields.Priority = 1; // Indicates the primary street name.
streetNameFields.StreetNameFieldName = "FULL_NAME";
// Add the StreetNameFields object to a new NetworkSourceDirections object,
// then add it to the EdgeFeatureSource created earlier.
INetworkSourceDirections nsDirections = new NetworkSourceDirectionsClass();
IArray nsdArray = new ArrayClass();
nsdArray.Add(streetNameFields);
nsDirections.StreetNameFields = nsdArray;
edgeNetworkSource.NetworkSourceDirections = nsDirections;
[VB.NET]
deND.SupportsTurns = True
' Create a new TurnFeatureSource object and point it to the ParisTurns feature class.
Dim turnNetSource As INetworkSource = New TurnFeatureSource
turnNetSource.Name = "ParisTurns"
turnNetSource.ElementType = esriNETTurn
[C#]
deNetworkDataset.SupportsTurns = true;
// Create a new TurnFeatureSource object and point it to the ParisTurns feature class.
INetworkSource turnNetworkSource = new TurnFeatureSourceClass();
turnNetworkSource.Name = "ParisTurns";
turnNetworkSource.ElementType = esriNetworkElementType.esriNETTurn;
[VB.NET]
Dim sourceArray As IArray = New ESRI.ArcGIS.esriSystem.Array
With sourceArray
.Add(edgeNetSource)
.Add(turnNetSource)
End With
deND.Sources = sourceArray
[C#]
IArray sourceArray = new ArrayClass();
sourceArray.Add(edgeNetworkSource);
sourceArray.Add(turnNetworkSource);
deNetworkDataset.Sources = sourceArray;
[VB.NET]
Dim attrArray As IArray = New ESRI.ArcGIS.esriSystem.Array
[C#]
IArray attributeArray = new ArrayClass();
[VB.NET]
' Create a new EvaluatedNetworkAttribute object and populate its settings.
Dim evalNetAttr As IEvaluatedNetworkAttribute = New EvaluatedNetworkAttribute
Dim netAttr2 As INetworkAttribute2 = CType(evalNetAttr, INetworkAttribute2)
With netAttr2
.Name = "Oneway"
.UsageType = esriNAUTRestriction
.DataType = esriNADTBoolean
.Units = esriNAUUnknown
.UseByDefault = True
End With
' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
Dim netFieldEval As INetworkFieldEvaluator = New NetworkFieldEvaluator
netFieldEval.SetExpression("restricted", _
"restricted = False" & vbNewLine & _
"Select Case UCase([Oneway])" & vbNewLine & _
" Case ""N"", ""TF"", ""T"": restricted = True" & vbNewLine & _
"End Select")
evalNetAttr.Evaluator(edgeNetSource, esriNEDAlongDigitized) = netFieldEval
netFieldEval = New NetworkFieldEvaluator
netFieldEval.SetExpression("restricted", _
"restricted = False" & vbNewLine & _
"Select Case UCase([Oneway])" & vbNewLine & _
" Case ""N"", ""FT"", ""F"": restricted = True" & vbNewLine & _
"End Select")
evalNetAttr.Evaluator(edgeNetSource, esriNEDAgainstDigitized) = netFieldEval
Dim netConstEval As INetworkConstantEvaluator = New NetworkConstantEvaluator
netConstEval.ConstantValue = False 'False means Traversable (that is, not restricted).
evalNetAttr.DefaultEvaluator(esriNETEdge) = netConstEval
evalNetAttr.DefaultEvaluator(esriNETJunction) = netConstEval
evalNetAttr.DefaultEvaluator(esriNETTurn) = netConstEval
' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create a new EvaluatedNetworkAttribute object and populate its settings.
IEvaluatedNetworkAttribute oneWayAttribute = new EvaluatedNetworkAttributeClass();
INetworkAttribute2 oneWayNetworkAttribute2 = (INetworkAttribute2)oneWayAttribute;
oneWayNetworkAttribute2.Name = "Oneway";
oneWayNetworkAttribute2.UsageType =
esriNetworkAttributeUsageType.esriNAUTRestriction;
oneWayNetworkAttribute2.DataType = esriNetworkAttributeDataType.esriNADTBoolean;
oneWayNetworkAttribute2.Units = esriNetworkAttributeUnits.esriNAUUnknown;
oneWayNetworkAttribute2.UseByDefault = true;
// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
INetworkFieldEvaluator oneWayToFromNetworkFieldEvaluator = new
NetworkFieldEvaluatorClass();
INetworkEvaluator oneWayToFromNetworkEvaluator = (INetworkEvaluator)
oneWayToFromNetworkFieldEvaluator;
oneWayToFromNetworkFieldEvaluator.SetExpression("restricted",
"restricted = False\n\rSelect Case UCase([Oneway])\n\r Case \"N\", \"TF\", \"T\": restricted = True\n\rEnd Select");
oneWayAttribute.set_Evaluator(edgeNetworkSource,
esriNetworkEdgeDirection.esriNEDAlongDigitized, oneWayToFromNetworkEvaluator);
INetworkFieldEvaluator oneWayFromToNetworkFieldEvaluator = new
NetworkFieldEvaluatorClass();
INetworkEvaluator oneWayFromToNetworkEvaluator = (INetworkEvaluator)
oneWayFromToNetworkFieldEvaluator;
oneWayFromToNetworkFieldEvaluator.SetExpression("restricted",
"restricted = False\n\rSelect Case UCase([Oneway])\n\r Case \"N\", \"FT\", \"F\": restricted = True\n\rEnd Select");
oneWayAttribute.set_Evaluator(edgeNetworkSource,
esriNetworkEdgeDirection.esriNEDAgainstDigitized, oneWayFromToNetworkEvaluator);
INetworkConstantEvaluator oneWayNetworkConstantEvaluator = new
NetworkConstantEvaluatorClass();
INetworkEvaluator oneWayConstantNetworkEvaluator = (INetworkEvaluator)
oneWayNetworkConstantEvaluator;
oneWayNetworkConstantEvaluator.ConstantValue = false; // False = traversable
oneWayAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge,
oneWayConstantNetworkEvaluator);
oneWayAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction,
oneWayConstantNetworkEvaluator);
oneWayAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn,
oneWayConstantNetworkEvaluator);
// Add the attribute to the array.
attributeArray.Add(oneWayAttribute);
[VB.NET]
' Create a new EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr = New EvaluatedNetworkAttribute
netAttr2 = CType(evalNetAttr, INetworkAttribute2)
With netAttr2
.Name = "Minutes"
.UsageType = esriNAUTCost
.DataType = esriNADTDouble
.Units = esriNAUMinutes
.UseByDefault = True
End With
' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval = New NetworkFieldEvaluator
netFieldEval.SetExpression("[FT_Minutes]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNEDAlongDigitized) = netFieldEval
netFieldEval = New NetworkFieldEvaluator
netFieldEval.SetExpression("[TF_Minutes]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNEDAgainstDigitized) = netFieldEval
netConstEval = New NetworkConstantEvaluator
netConstEval.ConstantValue = 0
evalNetAttr.DefaultEvaluator(esriNETEdge) = netConstEval
evalNetAttr.DefaultEvaluator(esriNETJunction) = netConstEval
evalNetAttr.DefaultEvaluator(esriNETTurn) = netConstEval
' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create a new EvaluatedNetworkAttribute object and populate its settings.
IEvaluatedNetworkAttribute minutesAttribute = new EvaluatedNetworkAttributeClass();
INetworkAttribute2 minutesNetworkAttribute2 = (INetworkAttribute2)minutesAttribute;
minutesNetworkAttribute2.Name = "Minutes";
minutesNetworkAttribute2.UsageType = esriNetworkAttributeUsageType.esriNAUTCost;
minutesNetworkAttribute2.DataType = esriNetworkAttributeDataType.esriNADTDouble;
minutesNetworkAttribute2.Units = esriNetworkAttributeUnits.esriNAUMinutes;
minutesNetworkAttribute2.UseByDefault = true;
// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
INetworkFieldEvaluator ftMinutesNetworkFieldEvaluator = new
NetworkFieldEvaluatorClass();
INetworkEvaluator ftMinutesNetworkEvaluator = (INetworkEvaluator)
ftMinutesNetworkFieldEvaluator;
ftMinutesNetworkFieldEvaluator.SetExpression("[FT_Minutes]", "");
minutesAttribute.set_Evaluator(edgeNetworkSource,
esriNetworkEdgeDirection.esriNEDAlongDigitized, ftMinutesNetworkEvaluator);
INetworkFieldEvaluator tfMinutesNetworkFieldEvaluator = new
NetworkFieldEvaluatorClass();
INetworkEvaluator tfMinutesNetworkEvaluator = (INetworkEvaluator)
tfMinutesNetworkFieldEvaluator;
tfMinutesNetworkFieldEvaluator.SetExpression("[TF_Minutes]", "");
minutesAttribute.set_Evaluator(edgeNetworkSource,
esriNetworkEdgeDirection.esriNEDAgainstDigitized, tfMinutesNetworkEvaluator);
INetworkConstantEvaluator minutesNetworkConstantEvaluator = new
NetworkConstantEvaluatorClass();
INetworkEvaluator minutesConstantNetworkEvaluator = (INetworkEvaluator)
minutesNetworkConstantEvaluator;
minutesNetworkConstantEvaluator.ConstantValue = 0;
minutesAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge,
minutesConstantNetworkEvaluator);
minutesAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction,
minutesConstantNetworkEvaluator);
minutesAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn,
minutesConstantNetworkEvaluator);
// Add the attribute to the array.
attributeArray.Add(minutesAttribute);
[VB.NET]
' Create a new EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr = New EvaluatedNetworkAttribute
netAttr2 = CType(evalNetAttr, INetworkAttribute2)
With netAttr2
.Name = "Meters"
.UsageType = esriNAUTCost
.DataType = esriNADTDouble
.Units = esriNAUMeters
.UseByDefault = False
End With
' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval = New NetworkFieldEvaluator
netFieldEval.SetExpression("[Meters]", "")
evalNetAttr.Evaluator(edgeNetSource, esriNEDAlongDigitized) = netFieldEval
evalNetAttr.Evaluator(edgeNetSource, esriNEDAgainstDigitized) = netFieldEval
netConstEval = New NetworkConstantEvaluator
netConstEval.ConstantValue = 0
evalNetAttr.DefaultEvaluator(esriNETEdge) = netConstEval
evalNetAttr.DefaultEvaluator(esriNETJunction) = netConstEval
evalNetAttr.DefaultEvaluator(esriNETTurn) = netConstEval
' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create a new EvaluatedNetworkAttribute object and populate its settings.
IEvaluatedNetworkAttribute metersAttribute = new EvaluatedNetworkAttributeClass();
INetworkAttribute2 metersNetworkAttribute2 = (INetworkAttribute2)metersAttribute;
metersNetworkAttribute2.Name = "Meters";
metersNetworkAttribute2.UsageType = esriNetworkAttributeUsageType.esriNAUTCost;
metersNetworkAttribute2.DataType = esriNetworkAttributeDataType.esriNADTDouble;
metersNetworkAttribute2.Units = esriNetworkAttributeUnits.esriNAUMeters;
metersNetworkAttribute2.UseByDefault = false;
// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
INetworkFieldEvaluator metersNetworkFieldEvaluator = new NetworkFieldEvaluatorClass()
;
INetworkEvaluator metersNetworkEvaluator = (INetworkEvaluator)
metersNetworkFieldEvaluator;
metersNetworkFieldEvaluator.SetExpression("[Meters]", "");
metersAttribute.set_Evaluator(edgeNetworkSource,
esriNetworkEdgeDirection.esriNEDAlongDigitized, metersNetworkEvaluator);
metersAttribute.set_Evaluator(edgeNetworkSource,
esriNetworkEdgeDirection.esriNEDAgainstDigitized, metersNetworkEvaluator);
INetworkConstantEvaluator metersNetworkConstantEvaluator = new
NetworkConstantEvaluatorClass();
INetworkEvaluator metersConstantNetworkEvaluator = (INetworkEvaluator)
metersNetworkConstantEvaluator;
metersNetworkConstantEvaluator.ConstantValue = 0;
metersAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge,
metersConstantNetworkEvaluator);
metersAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction,
metersConstantNetworkEvaluator);
metersAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn,
metersConstantNetworkEvaluator);
// Add the attribute to the array.
attributeArray.Add(metersAttribute);
[VB.NET]
' Create a new EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr = New EvaluatedNetworkAttribute
netAttr2 = CType(evalNetAttr, INetworkAttribute2)
With netAttr2
.Name = "RoadClass"
.UsageType = esriNAUTDescriptor
.DataType = esriNADTInteger
.Units = esriNAUUnknown
.UseByDefault = False
End With
' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netFieldEval = New NetworkFieldEvaluator
netFieldEval.SetExpression("rc", _
"rc = 1 'Local road" & vbNewLine & _
"Select Case UCase([CFCC])" & vbNewLine & _
" Case ""A10"", ""A11"", ""A12"", ""A13"", ""A14"", ""A15"", ""A16"", ""A17"", ""A18"", ""A19""" & vbNewLine & _
" rc = 2 'Highway" & vbNewLine & _
" Case ""A60"", ""A63""" & vbNewLine & _
" rc = 3 'Ramp" & vbNewLine & _
" Case ""A65"", ""A66"", ""A68"", ""A69""" & vbNewLine & _
" rc = 4 'Ferry" & vbNewLine & _
" Case ""A62""" & vbNewLine & _
" rc = 5 'Roundabout" & vbNewLine & _
"End Select")
evalNetAttr.Evaluator(edgeNetSource, esriNEDAlongDigitized) = netFieldEval
evalNetAttr.Evaluator(edgeNetSource, esriNEDAgainstDigitized) = netFieldEval
netConstEval = New NetworkConstantEvaluator
netConstEval.ConstantValue = 0
evalNetAttr.DefaultEvaluator(esriNETEdge) = netConstEval
evalNetAttr.DefaultEvaluator(esriNETJunction) = netConstEval
evalNetAttr.DefaultEvaluator(esriNETTurn) = netConstEval
' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create a new EvaluatedNetworkAttribute object and populate its settings.
IEvaluatedNetworkAttribute roadClassAttribute = new EvaluatedNetworkAttributeClass();
INetworkAttribute2 roadClassNetworkAttribute2 = (INetworkAttribute2)
roadClassAttribute;
roadClassNetworkAttribute2.Name = "RoadClass";
roadClassNetworkAttribute2.UsageType =
esriNetworkAttributeUsageType.esriNAUTDescriptor;
roadClassNetworkAttribute2.DataType = esriNetworkAttributeDataType.esriNADTInteger;
roadClassNetworkAttribute2.Units = esriNetworkAttributeUnits.esriNAUUnknown;
roadClassNetworkAttribute2.UseByDefault = false;
// Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
INetworkFieldEvaluator roadClassNetworkFieldEvaluator = new
NetworkFieldEvaluatorClass();
INetworkEvaluator roadClassNetworkEvaluator = (INetworkEvaluator)
roadClassNetworkFieldEvaluator;
roadClassNetworkFieldEvaluator.SetExpression("rc",
"rc = 1 'Local road\n\rSelect Case UCase([CFCC])\n\r" +
" Case \"A10\", \"A11\", \"A12\", \"A13\", \"A14\", \"A15\", \"A16\", \"A17\", \"A18\", \"A19\"\n\r" + " rc = 2 'Highway\n\r" + " Case \"A60\", \"A63\"\n\r" + " rc = 3 'Ramp\n\r" + " Case \"A65\", \"A66\", \"A68\", \"A69\"\n\r" + " rc = 4 'Ferry\n\r" + " Case \"A62\"\n\r" + " rc = 5 'Roundabout\n\r" + "End Select");
roadClassAttribute.set_Evaluator(edgeNetworkSource,
esriNetworkEdgeDirection.esriNEDAlongDigitized, roadClassNetworkEvaluator);
roadClassAttribute.set_Evaluator(edgeNetworkSource,
esriNetworkEdgeDirection.esriNEDAgainstDigitized, roadClassNetworkEvaluator);
INetworkConstantEvaluator roadClassNetworkConstantEvaluator = new
NetworkConstantEvaluatorClass();
INetworkEvaluator roadClassConstantNetworkEvaluator = (INetworkEvaluator)
roadClassNetworkConstantEvaluator;
roadClassNetworkConstantEvaluator.ConstantValue = 0;
roadClassAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge,
roadClassConstantNetworkEvaluator);
roadClassAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction,
roadClassConstantNetworkEvaluator);
roadClassAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn,
roadClassConstantNetworkEvaluator);
// Add the attribute to the array.
attributeArray.Add(roadClassAttribute);
[VB.NET]
' Create a new EvaluatedNetworkAttribute object and populate its settings.
evalNetAttr = New EvaluatedNetworkAttribute
netAttr2 = CType(evalNetAttr, INetworkAttribute2)
With netAttr2
.Name = "TurnRestriction"
.UsageType = esriNAUTRestriction
.DataType = esriNADTBoolean
.Units = esriNAUUnknown
.UseByDefault = True
End With
' Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
netConstEval = New NetworkConstantEvaluator
netConstEval.ConstantValue = True 'True means Restricted.
evalNetAttr.Evaluator(turnNetSource, esriNEDNone) = netConstEval
netConstEval = New NetworkConstantEvaluator
netConstEval.ConstantValue = False 'False means Traversable (that is, not restricted).
evalNetAttr.DefaultEvaluator(esriNETEdge) = netConstEval
evalNetAttr.DefaultEvaluator(esriNETJunction) = netConstEval
evalNetAttr.DefaultEvaluator(esriNETTurn) = netConstEval
' Add the attribute to the array.
attrArray.Add(evalNetAttr)
[C#]
// Create a new EvaluatedNetworkAttribute object and populate its settings.
IEvaluatedNetworkAttribute turnAttribute = new EvaluatedNetworkAttributeClass();
INetworkAttribute2 turnNetworkAttribute2 = (INetworkAttribute2)turnAttribute;
turnNetworkAttribute2.Name = "TurnRestriction";
turnNetworkAttribute2.UsageType = esriNetworkAttributeUsageType.esriNAUTDescriptor;
turnNetworkAttribute2.DataType = esriNetworkAttributeDataType.esriNADTInteger;
turnNetworkAttribute2.Units = esriNetworkAttributeUnits.esriNAUUnknown;
turnNetworkAttribute2.UseByDefault = false;
INetworkConstantEvaluator turnTrueNetworkConstantEvaluator = new
NetworkConstantEvaluatorClass();
INetworkEvaluator turnTrueNetworkEvaluator = (INetworkEvaluator)
turnTrueNetworkConstantEvaluator;
turnTrueNetworkConstantEvaluator.ConstantValue = true;
turnAttribute.set_Evaluator(turnNetworkSource, esriNetworkEdgeDirection.esriNEDNone,
turnTrueNetworkEvaluator);
INetworkConstantEvaluator turnFalseNetworkConstantEvaluator = new
NetworkConstantEvaluatorClass();
INetworkEvaluator turnFalseNetworkEvaluator = (INetworkEvaluator)
turnFalseNetworkConstantEvaluator;
turnFalseNetworkConstantEvaluator.ConstantValue = false;
turnAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge,
turnFalseNetworkEvaluator);
turnAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction,
turnFalseNetworkEvaluator);
turnAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn,
turnFalseNetworkEvaluator);
// Add the attribute to the array.
attributeArray.Add(turnAttribute);
[VB.NET]
deND.Attributes = attrArray
[C#]
deNetworkDataset.Attributes = attributeArray;
[VB.NET]
' Create a NetworkDirections object and populate its settings.
Dim netDirections As INetworkDirections = New NetworkDirections
With netDirections
.DefaultOutputLengthUnits = esriNAUMiles
.LengthAttributeName = "Meters"
.TimeAttributeName = "Minutes"
.RoadClassAttributeName = "RoadClass"
End With
' Add the NetworkDirections object to the network dataset data element.
deND.Directions = netDirections
[C#]
// Create a NetworkDirections object and populate its settings.
INetworkDirections networkDirections = new NetworkDirectionsClass();
networkDirections.DefaultOutputLengthUnits = esriNetworkAttributeUnits.esriNAUMeters;
networkDirections.LengthAttributeName = "Meters";
networkDirections.TimeAttributeName = "Minutes";
networkDirections.RoadClassAttributeName = "RoadClass";
// Add the NetworkDirections object to the network dataset data element.
deNetworkDataset.Directions = networkDirections;
[VB.NET]
' Get the feature dataset extension and create the network dataset based on the data element.
Dim fdxc As IFeatureDatasetExtensionContainer = CType(fdsGDS, IFeatureDatasetExtensionContainer)
Dim fdx As IFeatureDatasetExtension = fdxc.FindExtension(esriDTNetworkDataset)
Dim dsc2 As IDatasetContainer2 = CType(fdx, IDatasetContainer2)
Dim netDataset As INetworkDataset = CType(dsc2.CreateDataset(deND), INetworkDataset)
' Once the network dataset is created, build it.
Dim netBuild As INetworkBuild = CType(netDataset, INetworkBuild)
netBuild.BuildNetwork(fdsGDS.Extent)
[C#]
// Get the feature dataset extension and create the network dataset based on the data element.
IFeatureDatasetExtensionContainer fdxContainer = (IFeatureDatasetExtensionContainer)
featureDataset;
IFeatureDatasetExtension fdExtension = fdxContainer.FindExtension
(esriDatasetType.esriDTNetworkDataset);
IDatasetContainer2 datasetContainer2 = (IDatasetContainer2)fdExtension;
IDEDataset deDataset = (IDEDataset)deNetworkDataset;
INetworkDataset networkDataset = (INetworkDataset)datasetContainer2.CreateDataset
(deDataset);
// Once the network dataset is created, build it.
INetworkBuild networkBuild = (INetworkBuild)networkDataset;
networkBuild.BuildNetwork(geoDataset.Extent);