示例#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");
        }
示例#2
0
        static void Main(string[] args)
        {
            RoadRoute rd=new RoadRoute();
            rd.AppendBroken(5212.03, 5200);
            rd.AppendIntersectPoint("JD0", 2699431.148, 526687.642, 0.000, 0.000, 0.000,0,0);
            rd.AppendIntersectPoint("JD1", 2699282.498, 526358.355, 405.000, 45.000, 45.000,0,0);
            rd.AppendIntersectPoint("JD2", 2698742.770, 525808.770, 450.000, 45.000, 45.000,0,0);
            rd.AppendIntersectPoint("JD3", 2698663.972, 525392.907, 700.000, 80.000, 80.000,0,0);
            rd.AppendIntersectPoint("JD4", 2698247.760, 524639.097, 1600.000, 0.000, 0.000,0,0);
            rd.AppendIntersectPoint("JD5", 2697931.409, 523405.577, 900.000, 100.000, 100.000,0,0);
            rd.AppendIntersectPoint("JD6", 2698832.719, 522098.837, 0.000, 0.000, 0.000,0,0);

            rd.AppendGradePoint("A0.000", 870.900, 0.000, 0.0000, 0.0000);
            rd.AppendGradePoint("A150.000", 870.557, 200000.000, 0.0000, 0.0000);
            rd.AppendGradePoint("A750.000", 868.757, 50000.000, 0.0000, 0.0000);
            rd.AppendGradePoint("A1120.000", 869.867, 25000.000, 0.0000, 0.0000);
            rd.AppendGradePoint("A1540.000", 866.807, 60000.000, 0.0000, 0.0000);
            rd.AppendGradePoint("A1900.000", 865.727, 20000.000, 0.0000, 0.0000);
            rd.AppendGradePoint("A2100.000",866.327,20000.000,0.0000,0.0000);
            rd.AppendGradePoint("A2470.000",865.217,30000.000,0.0000,0.0000);
            rd.AppendGradePoint("A2720.000",865.967,20000.000,0.0000,0.0000);
            rd.AppendGradePoint("A3650.000",863.177,120000.000,0.0000,0.0000);
            rd.AppendGradePoint("A4200.000",864.827,20000.000,0.0000,0.0000);
            rd.AppendGradePoint("A4800.000",861.311,60000.000,0.0000,0.0000);
            rd.AppendGradePoint("A5212.030",862.549,0.000,0.0000,0.0000);

            rd.GenerateRoute();

            for(double i=0;i<5200;i+=20)
            {
                string stk = i.ToString();
                double Xc, Yc,Hc;
                rd.CalcCenterCoord(stk, out Xc, out Yc);
                rd.CalcCenterHight(stk, out Hc);
                double Xl, Yl;
                rd.CalcSideCoord(stk, -25, out Xl, out Yl);
                double Xr, Yr;
                rd.CalcSideCoord(stk, 25, out Xr, out Yr);
            }
        }