Beispiel #1
0
        static void Main(string[] args)
        {
            int[]        arr1    = { 31, 15, 10, 2, 4, 2, 14, 23, 12, 66 };
            StrategySort sort    = new SelectionSort();
            Context      context = new Context(sort, arr1);

            context.Sort();
            context.PrintArray();

            int[] arr2 = { 1, 5, 10, 2, 4, 12, 14, 23, 12, 66 };
            sort    = new InsertionSort();
            context = new Context(sort, arr2);
            context.Sort();
            context.PrintArray();


            int[] arr3 = { 31, 15, 10, 2, 4, 2, 14, 23, 12, 66 };
            sort    = new BubbleSort();
            context = new Context(sort, arr3);

            context.Sort();
            context.PrintArray();


            string A = "A", B = "B";

            StrategyRoute route1 = new CyclingRoute();
            StrategyRoute route2 = new PublicTransportRoute();
            StrategyRoute route3 = new RoadRoute();
            StrategyRoute route4 = new WalkingRoute();
            StrategyRoute route5 = new SightseeingRoute();

            NavContext navContext = new NavContext(route1);

            Console.WriteLine(navContext.ToString() + "\n" + navContext.BuildRoute(A, B) + "\n");

            navContext = new NavContext(route2);
            Console.WriteLine(navContext.ToString() + "\n" + navContext.BuildRoute(A, B) + "\n");

            navContext = new NavContext(route3);
            Console.WriteLine(navContext.ToString() + "\n" + navContext.BuildRoute(A, B) + "\n");

            navContext = new NavContext(route4);
            Console.WriteLine(navContext.ToString() + "\n" + navContext.BuildRoute(A, B) + "\n");

            navContext = new NavContext(route5);
            Console.WriteLine(navContext.ToString() + "\n" + navContext.BuildRoute(A, B) + "\n");
        }
Beispiel #2
0
        /// <summary>
        /// Get walking route
        /// </summary>
        /// <param name="startPoint">The start point.</param>
        /// <param name="endPoint">The end point.</param>
        /// <returns>Walking route between points</returns>
        private WalkingRoute GetWalkingStepsForRoute(
            SqlGeography startPoint, 
            SqlGeography endPoint,
            IEnumerable<string> invalidDirections,
            IEnumerable<string> validWords,
            IEnumerable<string> invalidWords 
            )
        {
            var urlForDirection = GoogleMapHelper.CreateUrlForDirectionRequest(
                GeneralSettings.GoogleApiKey, startPoint, endPoint);
            var responce = GoogleMapHelper.GetResponceFromGoogleApi(urlForDirection);
            var token = responce.SelectToken(GoogleMapHelper.PolylinePointsToken);
            var points = GoogleMapHelper.DecodePolyline((string)token);
            var walkingRoute = new WalkingRoute
            {
                Name = string.Empty,
                MapPoints = points,
                Speed = GeneralSettings.WalkingSpeed,
                Steps = GoogleMapHelper.GetStepsOfDirection(responce, invalidDirections, validWords, invalidWords),
                Type = Transport.Walking,
                Length = GoogleMapHelper.GetDistanceOfDirection(responce),
                Time =
                    TimeSpan.FromMinutes(
                        this.GetTimeInMinutes(
                            GeneralSettings.WalkingSpeed, GoogleMapHelper.GetDistanceOfDirection(responce)))
            };

            return walkingRoute;
        }