Example #1
0
        /// <summary>
        /// Get the all the routes between two cities, which the distance is less
        /// than or equal to the target distance. The routes might not exist and 
        /// an exception will be thrown.
        /// </summary>
        /// <param name="startCityName">Name of the start city</param>
        /// <param name="finalCityName">Name of the final city</param>
        /// <param name="maxNumStops">Maximum number of stops</param>
        /// <param name="enforceExactStopCriteria">Enforce exact stop criteria</param>
        /// <returns>All the routes between two cities</returns>
        public IEnumerable<IRoute> GetRoutes(string startCityName, string finalCityName, int maxNumStops, bool enforceExactStopCriteria)
        {
            try
            {
                // Get the paths with imposed limitation
                var paths = !enforceExactStopCriteria ?
                    Network.GetPaths(startCityName, finalCityName, maxNumStops) :
                    Network.GetPaths(startCityName, finalCityName, maxNumStops, true);

                // Create the routes
                var routes = new List<IRoute>();

                foreach (var path in paths)
                {
                    // Create the route
                    var route = new Route();

                    // Set the route
                    SetupRoute(route, path);

                    routes.Add(route);
                }

                return routes;
            }
            catch
            {
                // Routes don't exist
                throw new CoreException(Resources.ICTRoutesDoNotExist);
            }
        }
Example #2
0
        /// <summary>
        /// Get the all the routes between two cities, which the distance is less
        /// than or equal to the target distance. The routes might not exist and 
        /// an exception will be thrown.
        /// </summary>
        /// <param name="startCityName">Name of the start city</param>
        /// <param name="finalCityName">Name of the final city</param>
        /// <param name="targetDistance">Name of the final city</param>
        /// <returns>All the routes between two cities within range</returns>
        public IEnumerable<IRoute> GetRoutesWithinRange(string startCityName, string finalCityName, int targetDistance)
        {
            try
            {
                // Get the paths with imposed limitation
                var paths = Network.GetPathsWithinRange(startCityName, finalCityName, targetDistance);

                // Create the routes
                var routes = new List<IRoute>();

                foreach (var path in paths)
                {
                    // Create the route
                    var route = new Route();

                    // Set the route
                    SetupRoute(route, path);

                    routes.Add(route);
                }

                return routes;
            }
            catch
            {
                // Routes don't exist
                throw new CoreException(Resources.ICTRoutesDoNotExist);
            }
        }
Example #3
0
        /// <summary>
        /// Get the sequential route of a collection of cities. The route might 
        /// not exist and an exception will be thrown.
        /// </summary>
        /// <returns>Sequential route of a collection of cities</returns>
        public IRoute GetRoute(IEnumerable<string> cityNames)
        {
            try
            {
                // Get the path
                var path = Network.GetPath(cityNames);

                // Create the route
                var route = new Route();

                // Set the route
                SetupRoute(route, path);

                return route;
            }
            catch
            {
                // Route doesn't exist
                throw new CoreException(Resources.ICTRouteDoesNotExist);
            }
        }