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


INAVRPResult.InternalRouteContext Property (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (NetworkAnalyst)  

INAVRPResult.InternalRouteContext Property

The NAContext for the internal route problem.

[Visual Basic .NET]
Public ReadOnly Property InternalRouteContext As INAContext
[C#]
public INAContext InternalRouteContext {get;}
[C++]
HRESULT get_InternalRouteContext(
  INAContext** routeContext
);
[C++]

Parameters routeContext [out, retval]
routeContext is a parameter of type INAContext

Product Availability

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

Remarks

The InternalRouteContext property provides access to the internally-managed Route NAContext object generated or updated by the VRP solver during its last Solve operation. This internal route NAContext can be used to generate directions for a given VRP instance.

If the INAVRPSolver.GenerateInternalRouteContext property is set to False, this property will return null. 

[C#]

This illustrates how you can access the INAVRPResult.InternalRouteContext and generate directions from it.


public
void GenerateDirections(ESRI.ArcGIS.NetworkAnalyst.INAVRPResult vrpResult, string routeName, string directionsFileName)


{


// Check to make sure we have a valid result


ESRI.ArcGIS.NetworkAnalyst.
INAResult naResult=vrpResult as ESRI.ArcGIS.NetworkAnalyst.INAResult;


if (!naResult.HasValidResult)


throw new ArgumentException("The result is invalid!");





// Get the internal route context from the VRP result


ESRI.ArcGIS.NetworkAnalyst.
INAContext naRouteContext=vrpResult.InternalRouteContext;





// Get the NAStreetDirectionsAgent from the internal route context


ESRI.ArcGIS.NetworkAnalyst.
INAStreetDirectionsAgent directionsAgent;


directionsAgent=naRouteContext.Agents.get_ItemByName(
"StreetDirectionsAgent") as INAStreetDirectionsAgent;





// Get the Routes FeatureClass from the route NAContext


ESRI.ArcGIS.Geodatabase.
IFeatureClass featureClass=naRouteContext.NAClasses.get_ItemByName("Routes") as IFeatureClass;





// Try to find a route with routeName. If we do, create a Set and add the route feature to it.


// Otherwise, just leave the Set null to return directions for all routes.


ESRI.ArcGIS.esriSystem.
ISet routeSet=null;


ESRI.ArcGIS.Geodatabase.
IQueryFilter queryFilter=new QueryFilterClass();


queryFilter.WhereClause=
"Name='" + routeName + "'";


ESRI.ArcGIS.Geodatabase.
IFeatureCursor featureCursor=featureClass.Search(queryFilter, false);


ESRI.ArcGIS.Geodatabase.
IFeature feature=featureCursor.NextFeature();


if (feature != null)


{


routeSet=
new ESRI.ArcGIS.esriSystem.SetClass();


routeSet.Add(feature);


}





// Generate directions and save them to an XML file


directionsAgent.Execute(routeSet,
null);


directionsAgent.DirectionsContainer.SaveAsXML(directionsFileName);


}


See Also

INAVRPResult Interface