ArcObjects Library Reference

Set OD Cost Matrix Properties Snippet

Set OD cost matrix solver parameters, including settings.

[C#]

///<summary>Set OD cost matrix solver parameters, including settings.</summary>
/// 
///<param name="naSolver">An INASolver interface.</param>
///<param name="defaultCutoff">A System.Object that is the default cutoff value to stop traversing. Ex: Nothing (VBNet) or null (C#)</param>
///<param name="defaultTargetDestinationCount">A System.Object that is the default number of destinations to find. Ex: Nothing (VBNet) or null (C#)</param>
///
///<returns>An INAODCostMatrixSolver2 with default parameters set.</returns>
///
///<remarks>Solving for 10 destinations will return the cost-distance to the 10 closest destinations from each origin. If this value is Nothing or null, all destinations will be found.</remarks>
public ESRI.ArcGIS.NetworkAnalyst.INAODCostMatrixSolver2 SetODCostMatrixProperties(ESRI.ArcGIS.NetworkAnalyst.INASolver naSolver, object defaultCutoff, object defaultTargetDestinationCount)
{

  // Set OD cost matrix solver parameters, including settings for...
  ESRI.ArcGIS.NetworkAnalyst.INAODCostMatrixSolver2 naODCostMatrixSolver = (ESRI.ArcGIS.NetworkAnalyst.INAODCostMatrixSolver2)naSolver;

  // ...default cutoff
  naODCostMatrixSolver.DefaultCutoff = defaultCutoff; 

  // ...number of destinations to find
  naODCostMatrixSolver.DefaultTargetDestinationCount = defaultTargetDestinationCount;

  // ...output
  naODCostMatrixSolver.OutputLines = ESRI.ArcGIS.NetworkAnalyst.esriNAOutputLineType.esriNAOutputLineStraight;
  naODCostMatrixSolver.MatrixResultType = ESRI.ArcGIS.NetworkAnalyst.esriNAODCostMatrixType.esriNAODCostMatrixFull;
  naODCostMatrixSolver.PopulateODLines = false;
  
  return naODCostMatrixSolver;

}
[Visual Basic .NET]

'''<summary>Set OD cost matrix solver parameters, including settings.</summary>
''' 
'''<param name="naSolver">An INASolver interface.</param>
'''<param name="defaultCutoff">A System.Object that is the default cutoff value to stop traversing. Ex: Nothing (VBNet) or null (C#)</param>
'''<param name="defaultTargetDestinationCount">A System.Object that is the default number of destinations to find. Ex: Nothing (VBNet) or null (C#)</param>
'''
'''<returns>An INAODCostMatrixSolver2 with default parameters set.</returns>
'''
'''<remarks>Solving for 10 destinations will return the cost-distance to the 10 closest destinations from each origin. If this value is Nothing or null, all destinations will be found.</remarks>
Public Function SetODCostMatrixProperties(ByVal naSolver As ESRI.ArcGIS.NetworkAnalyst.INASolver, ByVal defaultCutoff As System.Object, ByVal defaultTargetDestinationCount As System.Object) As ESRI.ArcGIS.NetworkAnalyst.INAODCostMatrixSolver2

  ' Set OD cost matrix solver parameters, including settings for...
  Dim naODCostMatrixSolver As ESRI.ArcGIS.NetworkAnalyst.INAODCostMatrixSolver2 = CType(naSolver, ESRI.ArcGIS.NetworkAnalyst.INAODCostMatrixSolver2)

  ' ...default cutoff
  naODCostMatrixSolver.DefaultCutoff = defaultCutoff 

  ' ...number of destinations to find
  naODCostMatrixSolver.DefaultTargetDestinationCount = defaultTargetDestinationCount

  ' ...output
  naODCostMatrixSolver.OutputLines = ESRI.ArcGIS.NetworkAnalyst.esriNAOutputLineType.esriNAOutputLineStraight
  naODCostMatrixSolver.MatrixResultType = ESRI.ArcGIS.NetworkAnalyst.esriNAODCostMatrixType.esriNAODCostMatrixFull
  naODCostMatrixSolver.PopulateODLines = False

  Return naODCostMatrixSolver

End Function


Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.NetworkAnalyst