예제 #1
0
        /// <summary>
        /// This method returns the direction (itinerary) between a starting and ending location
        /// </summary>
        /// <param name="startLocation">Starting location</param>
        /// <param name="endLocation">Ending location</param>
        /// <param name="segPref">specify the shortest or quickest route</param>
        /// <returns>a RouteItinerary - just the directions portion of a route</returns>
        public RouteItinerary GetRouteDirections(Location startLocation, Location endLocation, SegmentPreference segPref)
        {
            Route myRoute;

            try
            {
                if (startLocation == null)
                {
                    throw new System.ArgumentNullException("Start location cannot be null");
                }
                if (endLocation == null)
                {
                    throw new System.ArgumentNullException("End location cannot be null");
                }

                SegmentSpecification[] routeSegmentsSpec = new SegmentSpecification[2];
                routeSegmentsSpec[0] = new SegmentSpecification();
                routeSegmentsSpec[0].Waypoint = new Waypoint();
                routeSegmentsSpec[0].Waypoint.Name = startLocation.Entity.Name;
                routeSegmentsSpec[0].Waypoint.Location = startLocation;
                routeSegmentsSpec[0].Options = new SegmentOptions();
                routeSegmentsSpec[0].Options.Preference = segPref;
                routeSegmentsSpec[1] = new SegmentSpecification();
                routeSegmentsSpec[1].Waypoint = new Waypoint();
                routeSegmentsSpec[1].Waypoint.Name = endLocation.Entity.Name;
                routeSegmentsSpec[1].Waypoint.Location = endLocation;
                routeSegmentsSpec[1].Options = new SegmentOptions();
                routeSegmentsSpec[1].Options.Preference = segPref;

                RouteSpecification routeSpec = new RouteSpecification();
                routeSpec.DataSourceName = "MapPoint.NA";
                routeSpec.ResultMask = RouteResultMask.Itinerary;
                routeSpec.Segments = routeSegmentsSpec;

                myRoute = theMapPointRouteService.CalculateRoute(routeSpec);

            }
            catch (ArgumentNullException e)
            {
                throw e;  // rethrow for app to handle
            }
            catch (Exception e)
            {
                throw e;  // rethrow for app to handle

            }

            return myRoute.Itinerary;
        }
예제 #2
0
파일: Reference.cs 프로젝트: xxjeng/nuxleus
 /// <remarks/>
 public void CalculateRouteAsync(RouteSpecification specification, object userState) {
     if ((this.CalculateRouteOperationCompleted == null)) {
         this.CalculateRouteOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCalculateRouteOperationCompleted);
     }
     this.InvokeAsync("CalculateRoute", new object[] {
                 specification}, this.CalculateRouteOperationCompleted, userState);
 }
예제 #3
0
파일: Reference.cs 프로젝트: xxjeng/nuxleus
 /// <remarks/>
 public System.IAsyncResult BeginCalculateRoute(RouteSpecification specification, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("CalculateRoute", new object[] {
                 specification}, callback, asyncState);
 }
예제 #4
0
파일: Reference.cs 프로젝트: xxjeng/nuxleus
 /// <remarks/>
 public void CalculateRouteAsync(RouteSpecification specification) {
     this.CalculateRouteAsync(specification, null);
 }
예제 #5
0
파일: Reference.cs 프로젝트: xxjeng/nuxleus
 public Route CalculateRoute(RouteSpecification specification) {
     object[] results = this.Invoke("CalculateRoute", new object[] {
                 specification});
     return ((Route)(results[0]));
 }