Exemplo n.º 1
0
        public void ParseTheFlightPlan()
        {
            if (is_parsed)
            {
                return;
            }


            SingelFlight first_flight = new SingelFlight();

            first_flight.flight_id    = id_flight_plan;
            first_flight.longitude    = json_flight_plan.initial_location.longitude;
            first_flight.latitude     = json_flight_plan.initial_location.latitude;
            first_flight.date_time    = json_flight_plan.initial_location.date_time;
            first_flight.passengers   = json_flight_plan.passengers;
            first_flight.company_name = json_flight_plan.company_name;
            first_flight.is_external  = false;
            flights_list.Add(first_flight);
            foreach (JsonSegment seg in json_flight_plan.segments)
            {
                flights_list.Add(CreateSingelFlight(first_flight, seg));
            }

            is_parsed = true;
        }
Exemplo n.º 2
0
        public SingelFlight CreateSingelFlight(SingelFlight arg_singel_flight, JsonSegment segment)
        {
            SingelFlight singel_flight = new SingelFlight();

            singel_flight.flight_id = id_flight_plan;
            singel_flight.longitude = segment.longitude;
            singel_flight.latitude  = segment.latitude;
            FlightDateAndTime temp = new FlightDateAndTime(arg_singel_flight.date_time);

            temp.AddTimeInSeconds(segment.timespan_seconds);
            singel_flight.date_time = temp.ToString();

            singel_flight.passengers   = json_flight_plan.passengers;
            singel_flight.company_name = json_flight_plan.company_name;
            singel_flight.is_external  = false;

            return(singel_flight);
        }
Exemplo n.º 3
0
        private IEnumerable <FlightBetweenTwoSegments> CreateAnArrayOfFlightBetweenTwoSegments()
        {
            List <FlightBetweenTwoSegments> list_flights_two_segments = new List <FlightBetweenTwoSegments>();
            SingelFlight first_flight    = flights_list.First();
            bool         is_first_flight = true;

            foreach (SingelFlight sec_flight in flights_list)
            {
                if (is_first_flight)
                {
                    is_first_flight = false;
                    continue;
                }
                FlightBetweenTwoSegments fbts = new FlightBetweenTwoSegments(first_flight, sec_flight);
                list_flights_two_segments.Add(fbts);
                first_flight = sec_flight;
            }


            return(list_flights_two_segments);
        }
Exemplo n.º 4
0
        public SingelFlight CreateSingelFlightBetweenTwoFlights(string arg_time)
        {
            FlightDateAndTime time_first_flight = new FlightDateAndTime(first_flight.date_time);
            FlightDateAndTime time_sec_flight   = new FlightDateAndTime(sec_flight.date_time);
            FlightDateAndTime arg_time_date     = new FlightDateAndTime(arg_time);

            TimeSpan sub_first_from_sec      = time_sec_flight.SubtractDateAndTime(first_flight.date_time);
            TimeSpan sub_first_from_arg_time = arg_time_date.SubtractDateAndTime(first_flight.date_time);
            long     ticks_total             = sub_first_from_sec.Ticks;
            long     ticks_mid = sub_first_from_arg_time.Ticks;

            decimal temp      = ticks_mid / ticks_total;
            double  remainder = ((double)ticks_mid) / ticks_total;
            //long count = Math.DivRem(ticks_total, ticks_mid, out remainder);

            //TimeSpan remainderSpan = TimeSpan.FromTicks(remainder);
            double longitude;
            double latitude;

            if (first_flight.longitude > sec_flight.longitude)
            {
                longitude = first_flight.longitude - sec_flight.longitude;
                longitude = first_flight.longitude - longitude * remainder;
            }
            else if (first_flight.longitude == sec_flight.longitude)
            {
                longitude = first_flight.longitude;
            }
            else
            {
                longitude = sec_flight.longitude - first_flight.longitude;
                longitude = longitude * remainder + first_flight.longitude;
            }

            if (first_flight.latitude > sec_flight.latitude)
            {
                latitude = first_flight.latitude - sec_flight.latitude;
                latitude = first_flight.latitude - latitude * remainder;
            }
            else if (first_flight.latitude == sec_flight.latitude)
            {
                latitude = first_flight.latitude;
            }
            else
            {
                latitude = sec_flight.latitude - first_flight.latitude;
                latitude = latitude * remainder + first_flight.latitude;
            }

            SingelFlight singel_flight = new SingelFlight();

            singel_flight.flight_id = first_flight.flight_id;
            singel_flight.longitude = longitude;
            singel_flight.latitude  = latitude;

            singel_flight.date_time = arg_time;

            singel_flight.passengers   = first_flight.passengers;
            singel_flight.company_name = first_flight.company_name;
            singel_flight.is_external  = false;
            return(singel_flight);
        }
Exemplo n.º 5
0
 public FlightBetweenTwoSegments(SingelFlight first_flight, SingelFlight sec_flight)
 {
     this.first_flight = first_flight;
     this.sec_flight   = sec_flight;
 }