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


Set Service Area Properties Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Set Service Area Properties Snippet

Set service area solver parameters, including settings. Allows for one DefaultBreaks and one ExcludeSourcesFromPolygons to be set.

[C#]
///<summary>Set service area solver parameters, including settings. Allows for multiple DefaultBreaks and multiple ExcludeSourcesFromPolygons to be set.</summary>
/// 
///<param name="naSolver">An INASolver interface.</param>
///<param name="defaultBreaks">An IDoubleArray interface that specifies how many rings to compute around each facility. The breaks are specified as a double array of numbers like 2.0, 4.0, 6.0. This will result in three polygons around the facility at 2.0, 4.0 and 6.0 cumulative attribute value units from each facility.</param>
///<param name="trimPolygonDistance">A System.Double that is  the distance (based on units specified by TrimPolygonDistanceUnits) that the outer service area polygon should be from the source features.  This is useful to reduce the area of the outer service area polygon in sparse networks. Ex: 100</param>
///<param name="excludeSourcesFromPolygons">An IStringArray interface that specifies if certain network sources should be excluded from the service area polygon generation. A service area on a multi-modal network where only one mode is being used to compute the service area would get a more appropriate shape if other modes are excluded from the polygons. The exclude sources are specified as an array of strings like "Railroads", "Bridges" "Marshes".</param>
/// 
///<returns></returns>
/// 
///<remarks></remarks>
public ESRI.ArcGIS.NetworkAnalyst.INAServiceAreaSolver2 SetServiceAreaProperties(ESRI.ArcGIS.NetworkAnalyst.INASolver naSolver, ESRI.ArcGIS.esriSystem.IDoubleArray defaultBreaks, System.Double trimPolygonDistance, ESRI.ArcGIS.esriSystem.IStringArray excludeSourcesFromPolygons)
{

  // Set service area solver parameters, including settings for...
  ESRI.ArcGIS.NetworkAnalyst.INAServiceAreaSolver2 naServiceAreaSolver2=(ESRI.ArcGIS.NetworkAnalyst.INAServiceAreaSolver2)naSolver;

  // ...travel direction
  naServiceAreaSolver2.TravelDirection=ESRI.ArcGIS.NetworkAnalyst.esriNATravelDirection.esriNATravelDirectionFromFacility;

  // ...default break values
  naServiceAreaSolver2.DefaultBreaks=defaultBreaks;

  // ...line generation
  naServiceAreaSolver2.OutputLines=ESRI.ArcGIS.NetworkAnalyst.esriNAOutputLineType.esriNAOutputLineTrueShape;
  naServiceAreaSolver2.IncludeSourceInformationOnLines=false;
  naServiceAreaSolver2.OverlapLines=true;
  naServiceAreaSolver2.SplitLinesAtBreaks=false;

  // ...polygon generation
  naServiceAreaSolver2.OutputPolygons=ESRI.ArcGIS.NetworkAnalyst.esriNAOutputPolygonType.esriNAOutputPolygonSimplified;
  naServiceAreaSolver2.MergeSimilarPolygonRanges=false;
  naServiceAreaSolver2.OverlapPolygons=true;
  naServiceAreaSolver2.SplitPolygonsAtBreaks=true;
  naServiceAreaSolver2.TrimOuterPolygon=true;
  naServiceAreaSolver2.TrimPolygonDistance=trimPolygonDistance;
  naServiceAreaSolver2.TrimPolygonDistanceUnits=ESRI.ArcGIS.esriSystem.esriUnits.esriMeters;

  // ...sources excluded from polygon generation
  naServiceAreaSolver2.ExcludeSourcesFromPolygons=excludeSourcesFromPolygons;

  return naServiceAreaSolver2;

}
[Visual Basic .NET]
'''<summary>Set service area solver parameters, including settings. Allows for one DefaultBreaks and one ExcludeSourcesFromPolygons to be set.</summary>
''' 
'''<param name="naSolver">An INASolver interface.</param>
'''<param name="oneDefaultBreak">A System.Double that specifies one ring to compute around each facility. Ex: 5.0</param>
'''<param name="trimPolygonDistance">A System.Double that is  the distance (based on units specified by TrimPolygonDistanceUnits) that the outer service area polygon should be from the source features.  This is useful to reduce the area of the outer service area polygon in sparse networks. Ex: 100</param>
'''<param name="oneExcludeSourceFromPolygon">A System.String that specifies one network source should be excluded from the service area polygon generation. Ex: "Railroads"</param>
''' 
'''<returns></returns>
''' 
'''<remarks></remarks>
Public Function SetServiceAreaProperties(ByVal naSolver As ESRI.ArcGIS.NetworkAnalyst.INASolver, ByVal defaultBreaks As ESRI.ArcGIS.esriSystem.IDoubleArray, ByVal trimPolygonDistance As System.Double, ByVal excludeSourcesFromPolygons As ESRI.ArcGIS.esriSystem.IStringArray) As ESRI.ArcGIS.NetworkAnalyst.INAServiceAreaSolver2
{

  ' Set service area solver parameters, including settings for...
  Dim naServiceAreaSolver2 As ESRI.ArcGIS.NetworkAnalyst.INAServiceAreaSolver2=CType(naSolver, ESRI.ArcGIS.NetworkAnalyst.INAServiceAreaSolver2)

  ' ...travel direction
  naServiceAreaSolver2.TravelDirection=ESRI.ArcGIS.NetworkAnalyst.esriNATravelDirection.esriNATravelDirectionFromFacility

  ' ...default break values
  naServiceAreaSolver2.DefaultBreaks=defaultBreaks 

  ' ...line generation
  naServiceAreaSolver2.OutputLines=ESRI.ArcGIS.NetworkAnalyst.esriNAOutputLineType.esriNAOutputLineTrueShape
  naServiceAreaSolver2.IncludeSourceInformationOnLines=False
  naServiceAreaSolver2.OverlapLines=True
  naServiceAreaSolver2.SplitLinesAtBreaks=False

  ' ...polygon generation
  naServiceAreaSolver2.OutputPolygons=ESRI.ArcGIS.NetworkAnalyst.esriNAOutputPolygonType.esriNAOutputPolygonSimplified
  naServiceAreaSolver2.MergeSimilarPolygonRanges=False
  naServiceAreaSolver2.OverlapPolygons=True
  naServiceAreaSolver2.SplitPolygonsAtBreaks=True
  naServiceAreaSolver2.TrimOuterPolygon=True
  naServiceAreaSolver2.TrimPolygonDistance=trimPolygonDistance
  naServiceAreaSolver2.TrimPolygonDistanceUnits=ESRI.ArcGIS.esriSystem.esriUnits.esriMeters

  ' ...sources excluded from polygon generation
  naServiceAreaSolver2.ExcludeSourcesFromPolygons=excludeSourcesFromPolygons

  Return naServiceAreaSolver2

End Function

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