ArcObjects Library Reference  (NetworkAnalyst)    

INATraversalResultQuery Interface

Provides access to the results of an analysis.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server. Requires Network Analyst Extension.

Members

Description
Read-only property ElementIDFieldName The element ID field name.
Read-only property FeatureClass The feature class by element type.
Read-only property FromEdgeIDFieldName The from edge ID field name.
Read-only property FromJunctionIDFieldName The from junction ID field name.
Read-only property FromPositionFieldName The from position field name.
Method SearchConnected Returns a connected set of elements in the result.
Read-only property SourceIDFieldName The source ID field name.
Read-only property SourceOIDFieldName The source OID field name.
Read-only property ToEdgeIDFieldName The to edge ID field name.
Read-only property ToJunctionIDFieldName The to junction ID field name.
Read-only property ToPositionFieldName The to position field name.

CoClasses that implement INATraversalResultQuery

CoClasses and Classes Description
NATraversalResult Contains the result of a network analysis.

Remarks

The INATraversalResultQuery interface is used to navigate through the traversal result and to provide the field names for various fields on the traversal classes.

You can use the properties ending with "FieldName" to get the fields holding the information about what the NATraversalResultElement is referencing.  Here is a description about what each field holds:

Use the FeatureClass property to return a feature class holding all the NATraversalResultElements of a specific type (esriNETJunction, esriNETEdge, esriNETTurn).  This feature class can be accessed like any other feature class in ArcGIS.

Use the SearchConnected method to return the NATraversalResultElements that are connected to the input NATraversalResultElement.

[C#]

This C# example shows how you can add a feature class returned by the FeatureClass property on INATraversalResultQuery to a map.

public void AddNATraversalResultToMap(INALayer naLayer, IMap map)
{
  INATraversalResultQuery traversalResultQuery = naLayer.Context.Result;
  INATraversalResultEdit naTraversalResultEdit = traversalResultQuery as INATraversalResultEdit;
  
  // Infer Geometry
  naTraversalResultEdit.InferGeometry(string.Empty, null, new CancelTrackerClass());
  
  // Get the Edges and add as a layer
  IFeatureLayer featureLayer = new FeatureLayerClass();
  featureLayer.FeatureClass = traversalResultQuery.get_FeatureClass(esriNetworkElementType.esriNETEdge);
  featureLayer.Name = featureLayer.FeatureClass.AliasName;
  map.AddLayer(featureLayer);
  
  // Get the Junctions and add as a layer
  featureLayer = new FeatureLayerClass();
  featureLayer.FeatureClass = traversalResultQuery.get_FeatureClass(esriNetworkElementType.esriNETJunction);
  featureLayer.Name = featureLayer.FeatureClass.AliasName;
  map.AddLayer(featureLayer);
}
[Visual Basic 6.0]

This Visual Basic example shows how you can add a feature class returned by the FeatureClass property on INATraversalResultQuery to ArcMap.

Public Sub AddNATraversalResultToArcMap()
  Dim pMxDoc As IMxDocument
  Dim pNetworkAnalystExtension As INetworkAnalystExtension
  Dim pNALayer As INALayer
  Dim pFLayer As IFeatureLayer
  Dim pTraversalResultQuery As INATraversalResultQuery
  Dim pNATraversalResultEdit As INATraversalResultEdit
  
  Set pMxDoc = ThisDocument
  Set pNetworkAnalystExtension = Application.FindExtensionByName("Network Analyst")
  Set pNALayer = pNetworkAnalystExtension.NAWindow.ActiveAnalysis
  Set pTraversalResultQuery = pNALayer.Context.Result
  Set pNATraversalResultEdit = pTraversalResultQuery
  
  'Infer Geometry
  pNATraversalResultEdit.InferGeometry "", Nothing, New CancelTracker
  
  'Get the Edges and add as a layer
  Set pFLayer = New FeatureLayer
  Set pFLayer.FeatureClass = pTraversalResultQuery.FeatureClass(esriNETEdge)
  pFLayer.Name = pFLayer.FeatureClass.AliasName
  pMxDoc.FocusMap.AddLayer pFLayer
  
  'Get the Junctions and add as a layer
  Set pFLayer = New FeatureLayer
  Set pFLayer.FeatureClass = pTraversalResultQuery.FeatureClass(esriNETJunction)
  pFLayer.Name = pFLayer.FeatureClass.AliasName
  pMxDoc.FocusMap.AddLayer pFLayer
End Sub
[Visual Basic .NET]

This VB.NET example shows how you can add a feature class returned by the FeatureClass property on INATraversalResultQuery to a map.

Public Sub AddNATraversalResultToMap(ByVal naLayer As INALayer, ByVal map As IMap)
    Dim traversalResultQuery As INATraversalResultQuery = naLayer.Context.Result
    Dim naTraversalResultEdit As INATraversalResultEdit = traversalResultQuery
    ' Infer Geometry
    naTraversalResultEdit.InferGeometry(String.Empty, Nothing, New CancelTracker())
    ' Get the Edges and add as a layer
    Dim featureLayer As IFeatureLayer = New FeatureLayer()
    featureLayer.FeatureClass = traversalResultQuery.FeatureClass(esriNetworkElementType.esriNETEdge)
    featureLayer.Name = featureLayer.FeatureClass.AliasName
    map.AddLayer(featureLayer)
    ' Get the Junctions and add as a layer
    featureLayer = New FeatureLayer()
    featureLayer.FeatureClass = traversalResultQuery.FeatureClass(esriNetworkElementType.esriNETJunction)
    featureLayer.Name = featureLayer.FeatureClass.AliasName
    map.AddLayer(featureLayer)
End Sub


 

 


Feedback Send feedback on this page