Ejemplo n.º 1
0
        //if theres flight in segment add to flight and retun true, else return false
        private bool newFlight(FlightPlan item, DateTime startTime, DateTime data, DateTime timespan,
                               List <Segment> flightSegments, int i, double timeInSegment, List <Flight> flights)
        {
            if (startTime <= data && timespan >= data)
            {
                double x1, y1, x, y, startY, startX;
                //if the first segment in fp
                if (i == 0)
                {
                    startX = item.initial_location.latitude;
                    startY = item.initial_location.longitude;
                }
                else
                {
                    startX = flightSegments[i - 1].latitude;
                    startY = flightSegments[i - 1].longitude;
                }

                //find plan location
                x1 = flightSegments[i].latitude - startX;
                x  = startX + timeInSegment * (x1 / flightSegments[i].timespan_seconds);

                y1 = flightSegments[i].longitude - startY;
                y  = startY + timeInSegment * (y1 / flightSegments[i].timespan_seconds);

                Flight flight = new Flight
                {
                    passengers   = item.passengers,
                    company_name = item.company_name,
                    flight_id    = flightsManager.GetId(item),
                    longitude    = y,
                    latitude     = x,
                    date_time    = item.initial_location.date_time,
                    is_external  = false
                };

                flights.Add(flight);
                return(true);
            }
            return(false);
        }