Route WebService Sample



Description:

This sample is a stand-alone application that shows how to programmatically perform point-to-point routing using the Network Analyst server extension connecting to a network analysis web service. This sample demonstrates some of the key programming patterns when using Network Analyst server objects such as:

  1. Connecting to the web service.
  2. Accessing solver properties from a Route analysis layer.
  3. Creating stop locations from a set of X,Y coordinates.
  4. Setting NAServer Route solver parameters.
  5. Solving to find the best route.
  6. Accessing NAServer result objects (map showing the route, driving directions, input and output NAClasses).

Data requirements:

  1. The Network Analyst sample data for the San Francisco region can be used to create the required server objects. To use your own data with this sample, refer to the documentation on designing and building a network dataset in the ArcGIS Desktop Help > Contents tab > Extensions > Network Analyst.
  2. The network dataset must be built with at least one cost attribute, likely based on distance. Optionally, you can add more cost attributes based on time units for example, add restrictions, or add direction information in order to generate driving directions.
  3. The map document must contain the network dataset, a Route analysis layer, and a point feature layer.

Products:
ArcView: C#, VB.NET
Engine: C#, VB.NET
Server: C#, VB.NET

Extension: Network Analyst

Platforms: Windows

Minimum ArcGIS Release: 9.2

How to use:
[NET, .NET, C#, VB.NET]
  1. Publish a network analysis service
    1. Open ArcCatalog
    2. Browse to [Your ArcGIS install folder]\DeveloperKit\SamplesNET\Server\data\SanFranciscoNetwork
    3. Right-click on SanFrancisco.mxd and click on "Publish to ArcGIS Server..."
    4. Enter 'SanFrancisco' as the Service Name
    5. Click Next
    6. Ensure "Network Analysis" is checked and click Next
    7. Click Finish
  2. Execute the sample
    1. Open the Route_WebService.sln.
    2. In the Solution Explorer, Right click on References, then select Add Web Reference.
    3. Type in the URL "http://localhost/arcgis/services/SanFrancisco/MapServer/NAServer.agsx?wsdl" (change localhost if the ArcGIS server is on a different machine) and click Go
    4. Change the Web Reference Name from "localhost" to "WebService"
    5. Click Add Reference
    6. Build and run the project
    7. Choose the route solver options
    8. Click the Find Route button
    9. Click on the different tabs to get the solver results

Download the C# files
Route_WebServiceClass.cs C# form.
Route_WebService.csproj The project file.
Route_WebService.sln The solution file.
Route_WebService.resx A project file.
Download the VB.NET files
Route_WebServiceClass.vb VB.NET form.
Route_WebService.vbproj The project file.
Route_WebService.sln The solution file.
Route_WebService.resx A project file.

Download the files for all languages



Key Libraries: NetworkAnalyst
Key CoClasses:NAServer, NAServerNetworkDescription, NAServerRouteParams, NAServerRouteResults, NAStreetDirections
Key Interfaces: INAServer, INAServerNetworkDescription, INAServerSolverParams, INAServerSolverResults, INAServerRouteParams, INAServerRouteResults, INASolverSettings, INARouteSolver, INARouteSolver2, INAStreetDirections
Key Members:INAServer::Solve, INAServer::GetNALayerNames, INAServer::GetNetworkDescription, INAServer::GetSolverParameters, INAServerSolverParams::ReturnMap, INAServerSolverResults::SolveMessages, INAServerSolverResults::MapImage, INAServerRouteParams::Stops, INAServerRouteParams::ReturnDirections, INAServerRouteResults::Directions, INAServerRouteResults::Routes, INAServerRouteResults::RouteGeometries, INAServerRouteResults::Stops, INAServerRouteResults::Total_Impedances