Ejemplo n.º 1
0
        //create a flight object with all the fields.
        public Flights createFlight(FlightPlan FlightPlan, string Id, string relativeTo)
        {
            bool    externalList = checkSyncAll(relativeTo);
            Flights Flights      = new Flights();
            int     i;

            //check in which segment the flight is currently in.
            for (i = 0; i < FlightPlan.segmentsList.Count; i++)
            {
                TimeSpan start;
                if (i == 0)
                {
                    start = TimeSpan.Parse(FlightPlan.loc.date_time.Substring(11, 8));
                }
                else
                {
                    start = TimeSpan.Parse(FlightPlan.segmentsList[i - 1].endTime.Substring(11, 8));
                }
                TimeSpan end = TimeSpan.Parse(FlightPlan.segmentsList[i].endTime.Substring(11, 8));
                TimeSpan now = TimeSpan.Parse(relativeTo.Substring(11, 8));
                //check the current longtitude and latitide.
                if (checkSegment(FlightPlan, start, end, now))
                {
                    Flights.longitude = CheckRangeLong(i, FlightPlan, relativeTo);
                    Flights.latitude  = CheckRangeLat(i, FlightPlan, relativeTo);
                    break;
                }
            }
            //add the rest of the fields.
            Flights.passengers   = FlightPlan.passengers;
            Flights.company_name = FlightPlan.company_name;
            Flights.date_time    = FlightPlan.loc.date_time;
            Flights.is_external  = FlightPlan.is_external;
            Flights.Flight_id    = Id;
            //return the flight.
            return(Flights);
        }
Ejemplo n.º 2
0
 //add flight to the list of flights.
 public void AddFlight(Flights f)
 {
     FlightList.Add(f);
 }