Routing on disconnected clients with SDC data

Introduction

Routing is based on a few objects that leverage the NAVMAP data format and its routing capabilities. The core routing objects include a router, stops, barriers, directions, and tracker that can provide a route with turn-by-turn directions and track progress.

A routing service enables routing in the application by referencing a Routing Service file (*.rs extension). A Routing Service file, or RS file, is an XML-formatted file that maps fields in the streets' network file to the fields required for routing. A Routing Service file also references the routing index files and any other supporting files, such as speed tables and signpost files. The routing service can be initialized by calling the RouterFactoryClass::CreateRouter method, which returns an IRouter object. Once the routing service is initialized, the router can be accessed, which enables route calculations and route tracking. Only one routing service can be defined in a NAVMAP file.

Code snippets

The Router class, is used to calculate routes and generate driving directions, and is initialized using the RS file on disk. The RS file, which is generally named streets.rs, is an XML-formatted file that maps fields in the streets' network file to the fields required for routing, and also references the routing index files and any other supporting files, such as speed tables and signpost files.

RouterFactoryClass rfc = new RouterFactoryClass();
_route = rfc.CreateRouter(@"C:\\data\StreetMap_Mobile\NorthAmerica\NAVTEQ_2011_Q4_NA_Mobile\Streets.rs");

The router calculates a route based on the stops that are passed to it with the StopsCollection object. StopsCollection is a container for Stop objects, which represent individual route stops. Before adding stops to the StopCollection, define the stop properties. At a minimum, the geometry of the stop must be specified by the Stop::geometry property. If only the Point property is defined for the route, then only simple point-to-point routing is available. To enable route tracking and map matching (network snapping), define the StopClass::Bearing, Speed, and Latency properties. Their values can be derived from the GPS connection through the SpeedGroupInfo properties.

Stop s = new Stop(result[i].Label, result[i].Coordinate);
        _addresses.Add(s);
        _addressesSketchLayer.GeometryBag.Add(s.Geometry);

Once the stops have been defined, the router is used to create a route and return directions with both turn-by-turn instructions, and the route geometry.

IDirections directions = _route.Solve(stopsCollection, null);
IDirectionsSummary summary = directions.Summary;
IDirectionCollection directionCollection = directions.Items;

Where to get the sample

The sample is available for download from the ArcGIS.com code gallery. .

1/7/2015