Пример #1
0
        // GetTravelData METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn			List<RouteData> GetTravelData(int OriginID, int DestinationID, bool FLTorLTL)
         *	\brief		This method will determine the info for a trip the between to cities.
         *	\details	A list of RouteData structs, each struct will hold all timing and KM data.
         *	            The timing for each element will keep track of the pick up time at the origin city, the drop off time at the destination, and the LTL time at intermediate cities.
         *	\param[in]	int OriginID, int DestinationID, bool FLTorLTL  The origin and destination cities, and if the trip is Flt or Ltl.
         *	\param[out]	null
         *	\exception	null
         *	\see		Struct: RouteData
         *	\return		List<RouteData> A list of the RouteData structs. The list all together will hold all the data for a trip.
         *
         * ---------------------------------------------------------------------------------------------------- */
        public List <RouteData> GetTravelData(int OriginID, int DestinationID, bool FLTorLTL) //ftl is true
        {
            //figure out if we need to travel east or west
            CityNode current = nodes.Find(x => x.CityID == OriginID);
            CityNode nextCity;

            List <RouteData> returnList = new List <RouteData>();

            if (OriginID >= 0 && OriginID < Number_of_Cities && DestinationID >= 0 && DestinationID < Number_of_Cities && OriginID != DestinationID)
            {
                do
                {
                    RouteData tripDataPassBack = new RouteData();

                    if (OriginID > DestinationID)
                    {
                        //going west
                        nextCity                    = current.West;
                        tripDataPassBack.KM         = current.WestKM;
                        tripDataPassBack.DrivenTime = current.WestHour;
                    }
                    else
                    {
                        //going east
                        nextCity                    = current.East;
                        tripDataPassBack.KM         = current.EastKM;
                        tripDataPassBack.DrivenTime = current.EastHour;
                    }

                    tripDataPassBack.CityA = current.CityID;
                    tripDataPassBack.CityB = nextCity.CityID;

                    if (current.CityID == OriginID)
                    {
                        tripDataPassBack.PickupTime += 2;
                    }

                    if (nextCity.CityID == DestinationID)
                    {
                        tripDataPassBack.DropoffTime += 2;
                    }

                    if (FLTorLTL && !(nextCity.CityID == DestinationID))
                    {
                        tripDataPassBack.LtlTime += 2;
                    }


                    returnList.Add(tripDataPassBack);

                    current = nextCity;
                } while (nextCity.CityID != DestinationID);

                return(returnList);
            }

            return(null);
        }
Пример #2
0
        // MappingClass Constructor HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn			MappingClass() Constructor
         *	\brief		The constructor for the Mapping Class
         *	\details	The data for each city will be read out of the database. It will then converted into a List datastructure so that it can be steped though easily.
         *	\param[in]	null
         *	\param[out]	null
         *	\exception	null
         *	\see		na
         *	\return		null
         *
         * ---------------------------------------------------------------------------------------------------- */
        public MappingClass()
        {
            CityNode Windsor    = new CityNode("Windsor", 0);
            CityNode London     = new CityNode("London", 1);
            CityNode Hamilton   = new CityNode("Hamilton", 2);
            CityNode Toronto    = new CityNode("Toronto", 3);
            CityNode Oshawa     = new CityNode("Oshawa", 4);
            CityNode Belleville = new CityNode("Belleville", 5);
            CityNode Kingston   = new CityNode("Kingston", 6);
            CityNode Ottawa     = new CityNode("Ottawa", 7);

            Windsor.West    = null;
            London.West     = Windsor;
            Hamilton.West   = London;
            Toronto.West    = Hamilton;
            Oshawa.West     = Toronto;
            Belleville.West = Oshawa;
            Kingston.West   = Belleville;
            Ottawa.West     = Kingston;

            Windsor.East    = London;
            London.East     = Hamilton;
            Hamilton.East   = Toronto;
            Toronto.East    = Oshawa;
            Oshawa.East     = Belleville;
            Belleville.East = Kingston;
            Kingston.East   = Ottawa;
            Ottawa.East     = null;

            nodes.Add(Windsor);
            nodes.Add(London);
            nodes.Add(Hamilton);
            nodes.Add(Toronto);
            nodes.Add(Oshawa);
            nodes.Add(Belleville);
            nodes.Add(Kingston);
            nodes.Add(Ottawa);

            int[] eastKMArray = new int[Number_of_Cities] {
                191, 128, 68, 60, 134, 82, 196, -1
            };
            for (int i = 0; i < Number_of_Cities; i++)
            {
                nodes[i].EastKM = eastKMArray[i];
            }

            int[] westKMArray = new int[Number_of_Cities] {
                -1, 191, 128, 68, 60, 134, 82, 196
            };
            for (int i = 0; i < Number_of_Cities; i++)
            {
                nodes[i].WestKM = westKMArray[i];
            }

            double[] eastHourArray = new double[Number_of_Cities] {
                2.5, 1.75, 1.25, 1.3, 1.65, 1.2, 2.5, -1
            };
            for (int i = 0; i < Number_of_Cities; i++)
            {
                nodes[i].EastHour = eastHourArray[i];
            }

            double[] WestHourArray = new double[Number_of_Cities] {
                -1, 2.5, 1.75, 1.25, 1.3, 1.65, 1.2, 2.5
            };
            for (int i = 0; i < Number_of_Cities; i++)
            {
                nodes[i].WestHour = WestHourArray[i];
            }

            int k = 0;
        }