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


Set Closest Facility Properties Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Set Closest Facility Properties Snippet

Set closest facility solver parameters, including settings.

[C#]
///<summary>Set closest facility 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="defaultTargetFacilityCount">A System.Int32 that is the default number of facilites to find. Ex: 1</param>
/// 
///<returns>An INAClosestFacilitySolver with default parameters set.</returns>
/// 
///<remarks></remarks>
public ESRI.ArcGIS.NetworkAnalyst.INAClosestFacilitySolver SetClosestFacilityProperties(ESRI.ArcGIS.NetworkAnalyst.INASolver naSolver, object defaultCutoff, System.Int32 defaultTargetFacilityCount)
{

  // Set closest facility solver parameters, including settings for...
  ESRI.ArcGIS.NetworkAnalyst.INAClosestFacilitySolver naClosestFacilitySolver=(ESRI.ArcGIS.NetworkAnalyst.INAClosestFacilitySolver)naSolver;

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

  // ...number of facilities to find
  naClosestFacilitySolver.DefaultTargetFacilityCount=defaultTargetFacilityCount;

  // ...travel direction
  naClosestFacilitySolver.TravelDirection=ESRI.ArcGIS.NetworkAnalyst.esriNATravelDirection.esriNATravelDirectionToFacility;

  // ...output
  naClosestFacilitySolver.CreateTraversalResult=true;
  naClosestFacilitySolver.OutputLines=ESRI.ArcGIS.NetworkAnalyst.esriNAOutputLineType.esriNAOutputLineTrueShape;

  return naClosestFacilitySolver;

}
[Visual Basic .NET]
'''<summary>Set closest facility 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="defaultTargetFacilityCount">A System.Int32 that is the default number of facilites to find. Ex: 1</param>
''' 
'''<returns>An INAClosestFacilitySolver with default parameters set.</returns>
''' 
'''<remarks></remarks>
Public Function SetClosestFacilityProperties(ByVal naSolver As ESRI.ArcGIS.NetworkAnalyst.INASolver, ByVal defaultCutoff As System.Object, ByVal defaultTargetFacilityCount As System.Int32) As ESRI.ArcGIS.NetworkAnalyst.INAClosestFacilitySolver

  ' Set closest facility solver parameters, including settings for...
  Dim naClosestFacilitySolver As ESRI.ArcGIS.NetworkAnalyst.INAClosestFacilitySolver=CType(naSolver, ESRI.ArcGIS.NetworkAnalyst.INAClosestFacilitySolver)

  ' ...default cutoff
  naClosestFacilitySolver.DefaultCutoff=defaultCutoff

  ' ...number of facilities to find
  naClosestFacilitySolver.DefaultTargetFacilityCount=defaultTargetFacilityCount

  ' ...travel direction
  naClosestFacilitySolver.TravelDirection=ESRI.ArcGIS.NetworkAnalyst.esriNATravelDirection.esriNATravelDirectionToFacility

  ' ...output
  naClosestFacilitySolver.CreateTraversalResult=True
  naClosestFacilitySolver.OutputLines=ESRI.ArcGIS.NetworkAnalyst.esriNAOutputLineType.esriNAOutputLineTrueShape

  Return naClosestFacilitySolver

End Function

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