예제 #1
0
 private void calcDiversionData()
 {
     track = Math.Atan2(Math.Cos(pos2.Lat * Math.PI / 180) * Math.Sin((pos2.Lng - pos1.Lng) * Math.PI / 180), Math.Cos(pos1.Lat * Math.PI / 180) * Math.Sin(pos2.Lat * Math.PI / 180) - Math.Sin(pos1.Lat * Math.PI / 180) * Math.Cos(pos2.Lat * Math.PI / 180) * Math.Cos((pos2.Lng - pos1.Lng) * Math.PI / 180)) * 180 / Math.PI;
     if (track < 0)
     {
         track += 360;
     }
     distance = DataConverters.LengthUnits((new MapRoute(new List <PointLatLng>()
     {
         pos1, pos2
     }, "L")).Distance, "KM", baseDistunit);
     calcTime();
     foreach (UIElement cnv in parent.Children)
     {
         if (cnv is Canvas)
         {
             foreach (UIElement stp in (cnv as Canvas).Children)
             {
                 if (stp is StackPanel)
                 {
                     if ((stp as StackPanel).Tag is CheckpointData)
                     {
                         if (((stp as StackPanel).Tag as CheckpointData).routenum == objID && ((stp as StackPanel).Tag as CheckpointData).linenum == componentID)
                         {
                             ((stp as StackPanel).Tag as CheckpointData).updateData();
                         }
                     }
                 }
             }
         }
     }
 }
예제 #2
0
 public void updateData(string mark)
 {
     if (mark == "neff")
     {
         double temp = parentData.neffectivedst;
         if (temp < 0)
         {
             return;
         }
         else
         {
             distance = temp;
         }
     }
     else if (mark == "eff")
     {
         double temp = DataConverters.LengthUnits(parentData.distance, parentData.baseDistunit, "KM") - parentData.effectivedst;
         if (temp < 0)
         {
             return;
         }
         else
         {
             distance = temp;
         }
     }
 }
예제 #3
0
 public CheckpointData(Line ml, Ellipse node, string mark)
 {
     isMark     = true;
     parentData = node.Tag as RouteData;
     routenum   = parentData.objID;
     linenum    = (ml.Tag as RouteData).componentID;
     if (mark == "neff")
     {
         distance = parentData.neffectivedst;
     }
     else if (mark == "eff")
     {
         distance = DataConverters.LengthUnits(parentData.distance, parentData.baseDistunit, "KM") - parentData.effectivedst;
     }
     this.mark = mark;
 }
예제 #4
0
 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
 {
     if (parameter.ToString() == "Checkpoint")
     {
         double pos    = System.Convert.ToDouble(values[0]);
         double height = System.Convert.ToDouble(values[1]);
         if (pos <= 0 || pos >= height)
         {
             return(Visibility.Hidden);
         }
         else
         {
             return(Visibility.Visible);
         }
     }
     else if (parameter is GMapControl)
     {
         GMapControl map     = parameter as GMapControl;
         double      height  = System.Convert.ToDouble(values[0]);
         RouteData   dat     = values[1] as RouteData;
         double      pos     = System.Convert.ToDouble(values[2]);
         double      climb   = dat.neffectivedst;
         double      descend = DataConverters.LengthUnits(dat.distance, dat.baseDistunit, "KM") - dat.effectivedst;
         PointLatLng pnt1    = map.FromLocalToLatLng(0, 20);
         PointLatLng pnt2    = map.FromLocalToLatLng(200, 20);
         double      dist    = new MapRoute(new List <PointLatLng>()
         {
             pnt1, pnt2
         }, "B").Distance;
         double factor = dist / 200;
         if (height * factor < climb + descend)
         {
             return(Visibility.Hidden);
         }
         else if (pos == 0)
         {
             return(Visibility.Hidden);
         }
         else
         {
             return(Visibility.Visible);
         }
     }
     return(Visibility.Visible);
 }
        private void changeUnits(object sender, SelectionChangedEventArgs e)
        {
            if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
            {
                isUnitsFixed               = false;
                default_unitsBtn.Content   = "Fix Units";
                default_unitsBtn.IsEnabled = true;
            }
            switch ((sender as ComboBox).Name)
            {
            case "alt_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.alt = DataConverters.LengthUnits(param.alt, alt_units.Text, alt_units.SelectedValue.ToString());
                    }
                    performanceChart.Items.Refresh();
                }
                break;

            case "dist_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.climbdist   = DataConverters.LengthUnits(param.climbdist, dist_units.Text, dist_units.SelectedValue.ToString());
                        param.descenddist = DataConverters.LengthUnits(param.descenddist, dist_units.Text, dist_units.SelectedValue.ToString());
                    }
                    performanceChart.Items.Refresh();
                }
                break;

            case "speed_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    if (!String.IsNullOrEmpty(dataspd1.Text))
                    {
                        dataspd1.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd1.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd2.Text))
                    {
                        dataspd2.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd2.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd3.Text))
                    {
                        dataspd3.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd3.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd4.Text))
                    {
                        dataspd4.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd4.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd5.Text))
                    {
                        dataspd5.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd5.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                }
                break;

            case "fuel_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.climbfuel   = DataConverters.MassUnits(param.climbfuel, fuel_units.Text, fuel_units.SelectedValue.ToString());
                        param.descendfuel = DataConverters.MassUnits(param.descendfuel, fuel_units.Text, fuel_units.SelectedValue.ToString());
                    }
                    foreach (FuelStartData param in fsdata.fuelStartDatas)
                    {
                        param.startval = DataConverters.MassUnits(param.startval, fuel_units.Text, fuel_units.SelectedValue.ToString());
                    }
                    foreach (FuelReduceData param in frdata.fuelReduceDatas)
                    {
                        param.reductionval = DataConverters.MassUnits(param.reductionval, fuel_units.Text, fuel_units.SelectedValue.ToString());
                    }
                    performanceChart.Items.Refresh();
                    startFuelChart.Items.Refresh();
                    reductionFuelChart.Items.Refresh();
                }
                break;

            case "lfft_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    if (pdata.performanceDatas.Count != 0)
                    {
                        if (MessageBox.Show($"Changing This Unit Will Result in Resetting All the Existing {Environment.NewLine} Value Corresponding to This Unit {Environment.NewLine} {Environment.NewLine} Are you sure you want to proceed?", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.Cancel)
                        {
                            lfft_units.SelectionChanged -= changeUnits;
                            lfft_units.SelectedValue     = lfft_units.Text;
                            lfft_units.SelectionChanged += changeUnits;
                            return;
                        }
                    }
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.spd1 = DataConverters.ConsumptionUnits(param.spd1, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd2 = DataConverters.ConsumptionUnits(param.spd2, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd3 = DataConverters.ConsumptionUnits(param.spd3, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd4 = DataConverters.ConsumptionUnits(param.spd4, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd5 = DataConverters.ConsumptionUnits(param.spd5, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                    }
                    performanceChart.Items.Refresh();
                }
                break;

            default:
                return;
            }
        }
예제 #6
0
 private void calcData()
 {
     totaldistance = 0;
     totaltime     = 0;
     totalfuel     = 0;
     track         = Math.Atan2(Math.Cos(pos2.Lat * Math.PI / 180) * Math.Sin((pos2.Lng - pos1.Lng) * Math.PI / 180), Math.Cos(pos1.Lat * Math.PI / 180) * Math.Sin(pos2.Lat * Math.PI / 180) - Math.Sin(pos1.Lat * Math.PI / 180) * Math.Cos(pos2.Lat * Math.PI / 180) * Math.Cos((pos2.Lng - pos1.Lng) * Math.PI / 180)) * 180 / Math.PI;
     if (track < 0)
     {
         track += 360;
     }
     for (int i = 0; i < parent.Children.Count; i++)
     {
         if (parent.Children[i] is Ellipse)
         {
             if (((parent.Children[i] as Ellipse).Tag as RouteData).objType == objType && ((parent.Children[i] as Ellipse).Tag as RouteData).objID == objID)
             {
                 if (((parent.Children[i] as Ellipse).Tag as RouteData).type == "Origin")
                 {
                     continue;
                 }
                 if (((parent.Children[i] as Ellipse).Tag as RouteData).type == "Diversion")
                 {
                     ((parent.Children[i] as Ellipse).Tag as RouteData).calcDiversionData();
                     continue;
                 }
                 ((parent.Children[i] as Ellipse).Tag as RouteData).distance = DataConverters.LengthUnits((new MapRoute(new List <PointLatLng>()
                 {
                     ((parent.Children[i] as Ellipse).Tag as RouteData).pos1, ((parent.Children[i] as Ellipse).Tag as RouteData).pos2
                 }, "L")).Distance, "KM", baseDistunit);
                 ((parent.Children[i] as Ellipse).Tag as RouteData).calcTime();
                 ((parent.Children[i] as Ellipse).Tag as RouteData).calcFuel();
                 ((parent.Children[i] as Ellipse).Tag as RouteData).lvldistance = ((parent.Children[i] as Ellipse).Tag as RouteData).effectivedst - ((parent.Children[i] as Ellipse).Tag as RouteData).neffectivedst;
                 totaldistance += ((parent.Children[i] as Ellipse).Tag as RouteData).distance;
                 totaltime     += ((parent.Children[i] as Ellipse).Tag as RouteData).time;
                 totalfuel     += ((parent.Children[i] as Ellipse).Tag as RouteData).fuel;
                 foreach (UIElement cnv in parent.Children)
                 {
                     if (cnv is Canvas)
                     {
                         foreach (UIElement stp in (cnv as Canvas).Children)
                         {
                             if (stp is StackPanel)
                             {
                                 if ((stp as StackPanel).Tag is CheckpointData)
                                 {
                                     if (((stp as StackPanel).Tag as CheckpointData).routenum == ((parent.Children[i] as Ellipse).Tag as RouteData).objID && ((stp as StackPanel).Tag as CheckpointData).linenum == ((parent.Children[i] as Ellipse).Tag as RouteData).componentID - 1)
                                     {
                                         ((stp as StackPanel).Tag as CheckpointData).updateData();
                                     }
                                 }
                             }
                         }
                     }
                 }
                 ((parent.Children[i] as Ellipse).Tag as RouteData).rev = true;
             }
         }
     }
     for (int i = parent.Children.Count - 1; i >= 0; i--)
     {
         if (parent.Children[i] is Ellipse)
         {
             if (((parent.Children[i] as Ellipse).Tag as RouteData).objType == objType && ((parent.Children[i] as Ellipse).Tag as RouteData).objID == objID)
             {
                 ((parent.Children[i] as Ellipse).Tag as RouteData).totaldistance = totaldistance;
                 ((parent.Children[i] as Ellipse).Tag as RouteData).totaltime     = totaltime;
                 ((parent.Children[i] as Ellipse).Tag as RouteData).totalfuel     = totalfuel;
                 if (((parent.Children[i] as Ellipse).Tag as RouteData).type == "Origin" || ((parent.Children[i] as Ellipse).Tag as RouteData).type == "Diversion")
                 {
                     continue;
                 }
                 ((parent.Children[i] as Ellipse).Tag as RouteData).calcFuel();
                 ((parent.Children[i] as Ellipse).Tag as RouteData).rev = false;
             }
         }
     }
 }
예제 #7
0
 public void calcFuel()
 {
     if (baseLfftunit == "PER KM")
     {
         if (type == "Starting")
         {
             if (rev)
             {
                 pullnextData();
                 frcsfuel = next_frcsfuel + fuel + sutto;
                 return;
             }
             if (distance < climbdist)
             {
                 fuel = 0;
             }
             else
             {
                 tocbodfuel  = climbfuel;
                 landingfuel = 0;
                 lvlfuel     = DataConverters.LengthUnits(distance - climbdist, baseDistunit, "KM") * lfft;
                 fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
             }
             remfuel = startingfuel - sutto;
         }
         else if (type == "Origin")
         {
             fuel     = 0;
             remfuel  = startingfuel - sutto;
             frcsfuel = 0;
         }
         else if (type == "Landing")
         {
             if (rev)
             {
                 landingfrcs = minima;
                 frcsfuel    = landingfrcs + fuel;
                 return;
             }
             if (componentID == 1)
             {
                 if (distance < climbdist + descenddist)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = climbfuel;
                     lvlfuel     = DataConverters.LengthUnits(distance - (climbdist + descenddist), baseDistunit, "KM") * lfft;
                     landingfuel = descendfuel;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
                 remfuel    = startingfuel - sutto;
                 landingrem = remfuel - fuel;
                 return;
             }
             if (alt > prev_alt)
             {
                 if (distance < (climbdist - prev_climbdist) + descenddist)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = (climbfuel - prev_climbfuel);
                     lvlfuel     = DataConverters.LengthUnits(distance - ((climbdist - prev_climbdist) + descenddist), baseDistunit, "KM") * lfft;
                     landingfuel = descendfuel;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
             }
             else if (alt < prev_alt)
             {
                 if (distance < (prev_descenddist - descenddist) + descenddist)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = (prev_descendfuel - descendfuel);
                     lvlfuel     = DataConverters.LengthUnits(distance - ((prev_descenddist - descenddist) + descenddist), baseDistunit, "KM") * lfft;
                     landingfuel = descendfuel;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
             }
             else
             {
                 if (distance < descenddist)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = 0;
                     lvlfuel     = DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM") * lfft;
                     landingfuel = descendfuel;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
             }
             remfuel    = prev_remfuel - prev_fuel;
             landingrem = remfuel - fuel;
         }
         else
         {
             if (rev)
             {
                 pullnextData();
                 frcsfuel = next_frcsfuel + fuel;
                 return;
             }
             if (alt > prev_alt)
             {
                 if (distance < climbdist - prev_climbdist)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = (climbfuel - prev_climbfuel);
                     lvlfuel     = DataConverters.LengthUnits(distance - (climbdist - prev_climbdist), baseDistunit, "KM") * lfft;
                     landingfuel = 0;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
             }
             else if (alt < prev_alt)
             {
                 if (distance < prev_descenddist - descenddist)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = (prev_descendfuel - descendfuel);
                     lvlfuel     = DataConverters.LengthUnits(distance - (prev_descenddist - descenddist), baseDistunit, "KM") * lfft;
                     landingfuel = 0;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
             }
             else
             {
                 tocbodfuel  = 0;
                 lvlfuel     = DataConverters.LengthUnits(distance, baseDistunit, "KM") * lfft;
                 landingfuel = 0;
                 fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
             }
             remfuel = prev_remfuel - prev_fuel;
         }
     }
     else if (baseLfftunit == "PER MIN")
     {
         if (type == "Starting")
         {
             if (rev)
             {
                 pullnextData();
                 frcsfuel = next_frcsfuel + fuel + sutto;
                 return;
             }
             if (time < climbtime)
             {
                 fuel = 0;
             }
             else
             {
                 tocbodfuel  = climbfuel;
                 lvlfuel     = TimeSpan.FromSeconds(time - climbtime).TotalMinutes *lfft;
                 landingfuel = 0;
                 fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
             }
             remfuel = startingfuel - sutto;
         }
         else if (type == "Origin")
         {
             fuel     = 0;
             remfuel  = startingfuel - sutto;
             frcsfuel = 0;
         }
         else if (type == "Landing")
         {
             if (rev)
             {
                 landingfrcs = minima;
                 frcsfuel    = landingfrcs + fuel;
                 return;
             }
             if (componentID == 1)
             {
                 if (time < climbtime + descendtime)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = climbfuel;
                     lvlfuel     = TimeSpan.FromSeconds(time - (climbtime + descendtime)).TotalMinutes *lfft;
                     landingfuel = descendfuel;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
                 remfuel    = startingfuel - sutto;
                 landingrem = remfuel - fuel;
                 return;
             }
             if (alt > prev_alt)
             {
                 if (time < (climbtime - prev_climbtime) + descendtime)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = (climbfuel - prev_climbfuel);
                     lvlfuel     = TimeSpan.FromSeconds(time - ((climbtime - prev_climbtime) + descendtime)).TotalMinutes *lfft;
                     landingfuel = descendfuel;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
             }
             else if (alt < prev_alt)
             {
                 if (time < (prev_descendtime - descendtime) + descendtime)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = (prev_descendfuel - descendfuel);
                     lvlfuel     = TimeSpan.FromSeconds(time - ((prev_descendtime - descendtime) + descendtime)).TotalMinutes *lfft;
                     landingfuel = descendfuel;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
             }
             else
             {
                 if (time < descendtime)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = 0;
                     lvlfuel     = TimeSpan.FromSeconds(time - descendtime).TotalMinutes *lfft;
                     landingfuel = descendfuel;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
             }
             remfuel    = prev_remfuel - prev_fuel;
             landingrem = remfuel - fuel;
         }
         else
         {
             if (rev)
             {
                 pullnextData();
                 frcsfuel = next_frcsfuel + fuel;
                 return;
             }
             if (alt > prev_alt)
             {
                 if (time < climbtime - prev_climbtime)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = (climbfuel - prev_climbfuel);
                     lvlfuel     = TimeSpan.FromSeconds(time - (climbtime - prev_climbtime)).TotalMinutes *lfft;
                     landingfuel = 0;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
             }
             else if (alt < prev_alt)
             {
                 if (time < prev_descendtime - descendtime)
                 {
                     fuel = 0;
                 }
                 else
                 {
                     tocbodfuel  = (prev_descendfuel - descendfuel);
                     lvlfuel     = TimeSpan.FromSeconds(time - (prev_descendtime - descendtime)).TotalMinutes *lfft;
                     landingfuel = 0;
                     fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
                 }
             }
             else
             {
                 tocbodfuel  = 0;
                 lvlfuel     = TimeSpan.FromSeconds(time).TotalMinutes *lfft;
                 landingfuel = 0;
                 fuel        = tocbodfuel + lvlfuel + landingfuel + rdfuel;
             }
             remfuel = prev_remfuel - prev_fuel;
         }
     }
 }
예제 #8
0
 public void calcTime()
 {
     if (type == "Starting")
     {
         if (speed == 0)
         {
             time = 0;
         }
         else if (distance < climbdist)
         {
             time = 0;
         }
         else
         {
             transition      = @"climb";
             neffectivedst   = DataConverters.LengthUnits(climbdist, baseDistunit, "KM");
             effectivedst    = DataConverters.LengthUnits(distance, baseDistunit, "KM");
             checkpointconst = climbtime - TimeSpan.FromHours(DataConverters.LengthUnits(climbdist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
             lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - climbdist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
             tocbodtime      = climbtime;
             landingtime     = 0;
             time            = tocbodtime + lvltime + landingtime;
         }
     }
     else if (type == "Origin")
     {
         time = 0;
     }
     else if (type == "Landing" || type == "Diversion")
     {
         if (speed == 0)
         {
             time = 0;
         }
         else
         {
             pullprevData();
             if (type == "Landing" && componentID == 1)
             {
                 if (distance < descenddist + climbdist)
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"climb";
                     neffectivedst   = DataConverters.LengthUnits(climbdist, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM");
                     checkpointconst = climbtime + descendtime - TimeSpan.FromHours(DataConverters.LengthUnits(descenddist + climbdist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - (descenddist + climbdist), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = climbtime;
                     landingtime     = descendtime;
                     time            = tocbodtime + lvltime + landingtime;
                 }
                 return;
             }
             if (alt > prev_alt)
             {
                 if (distance < descenddist + (climbdist - prev_climbdist))
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"climb";
                     neffectivedst   = DataConverters.LengthUnits(climbdist - prev_climbdist, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM");
                     checkpointconst = (climbtime - prev_climbtime) + descendtime - TimeSpan.FromHours(DataConverters.LengthUnits(descenddist + (climbdist - prev_climbdist), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - (descenddist + (climbdist - prev_climbdist)), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = (climbtime - prev_climbtime);
                     landingtime     = descendtime;
                     time            = tocbodtime + lvltime + landingtime;
                 }
             }
             else if (alt < prev_alt)
             {
                 if (distance < descenddist + (prev_descenddist - descenddist))
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"descend";
                     neffectivedst   = DataConverters.LengthUnits(prev_descenddist - descenddist, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM");
                     checkpointconst = (prev_descendtime - descendtime) + descendtime - TimeSpan.FromHours(DataConverters.LengthUnits(descenddist + (prev_descenddist - descenddist), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - (descenddist + (prev_descenddist - descenddist)), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = (prev_descendtime - descendtime);
                     landingtime     = descendtime;
                     time            = tocbodtime + lvltime + descendtime;
                 }
             }
             else
             {
                 if (distance < descenddist)
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"flat";
                     neffectivedst   = DataConverters.LengthUnits(0, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM");
                     checkpointconst = descendtime - TimeSpan.FromHours(DataConverters.LengthUnits(descenddist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = 0;
                     landingtime     = descendtime;
                     time            = tocbodtime + lvltime + landingtime;
                 }
             }
         }
     }
     else
     {
         if (speed == 0)
         {
             time = 0;
         }
         else
         {
             pullprevData();
             if (alt > prev_alt)
             {
                 if (distance < climbdist - prev_climbdist)
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"climb";
                     neffectivedst   = DataConverters.LengthUnits(climbdist - prev_climbdist, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance, baseDistunit, "KM");
                     checkpointconst = (climbtime - prev_climbtime) - TimeSpan.FromHours(DataConverters.LengthUnits(climbdist - prev_climbdist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - (climbdist - prev_climbdist), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = (climbtime - prev_climbtime);
                     landingtime     = 0;
                     time            = tocbodtime + lvltime + landingtime;
                 }
             }
             else if (alt < prev_alt)
             {
                 if (distance < prev_descenddist - descenddist)
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"descend";
                     neffectivedst   = DataConverters.LengthUnits(prev_descenddist - descenddist, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance, baseDistunit, "KM");
                     checkpointconst = (prev_descendtime - descendtime) - TimeSpan.FromHours(DataConverters.LengthUnits(prev_descenddist - descenddist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - (prev_descenddist - descenddist), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = (prev_descendtime - descendtime);
                     landingtime     = 0;
                     time            = tocbodtime + lvltime + landingtime;
                 }
             }
             else
             {
                 transition      = @"flat";
                 neffectivedst   = DataConverters.LengthUnits(0, baseDistunit, "KM");
                 effectivedst    = DataConverters.LengthUnits(distance, baseDistunit, "KM");
                 checkpointconst = 0;
                 lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                 tocbodtime      = 0;
                 landingtime     = 0;
                 time            = tocbodtime + lvltime + landingtime;
             }
         }
     }
 }