Beispiel #1
0
        /// <summary>Resolves a point declared in competition coordinates (4 digit easting, 4 digit northing)
        /// </summary>
        /// <param name="goal"></param>
        /// <returns></returns>
        public AXWaypoint ResolveDeclaredGoal(GoalDeclaration goal)
        {
            //1e5 = 100km

            var easting = TopLeft.Easting - TopLeft.Easting % 1e5 + goal.Easting4Digits * 10;

            //check for major tick change (hundreds of km)
            if (!easting.IsBetween(TopLeft.Easting, BottomRight.Easting))
            {
                easting += 1e5;
            }

            var northing = BottomRight.Northing - BottomRight.Northing % 1e5 + goal.Northing4Digits * 10;

            //check for major tick change (hundreds of km)
            if (!northing.IsBetween(BottomRight.Northing, TopLeft.Northing))
            {
                northing += 1e5;
            }

            //check if it's inside the competition map
            if (easting.IsBetween(TopLeft.Easting, BottomRight.Easting) &&
                northing.IsBetween(BottomRight.Northing, TopLeft.Northing))
            {
                return(new AXWaypoint(goal.Number.ToString("00"), goal.Time, easting, northing, goal.Altitude));
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public bool RemoveDeclaredGoal(GoalDeclaration declaration)
        {
            var ok = DeclaredGoals.Remove(declaration);

            if (ok)
            {
                Notes.Add(string.Format("Goal declaration {0} removed by {1}", declaration, Debriefer));
                IsDirty = true;
            }
            return(ok);
        }
Beispiel #3
0
        private AXWaypoint TryResolveGoalDeclaration(GoalDeclaration goal, bool useDeclaredAltitude)
        {
            AXWaypoint tmpPoint = null;

            if (goal.Type == GoalDeclaration.DeclarationType.GoalName)
            {
                try
                {
                    tmpPoint = ((ScriptingPoint)Engine.Heap[goal.Name]).Point;
                }
                catch { }
            }
            else // competition coordinates
            {
                tmpPoint = Engine.Settings.ResolveDeclaredGoal(goal);
            }

            if (tmpPoint == null)
            {
                throw new InvalidOperationException("could not resolve goal declaration");
            }

            var altitude = 0.0;

            if (useDeclaredAltitude && !double.IsNaN(goal.Altitude))
            {
                altitude = goal.Altitude;
                AddNote(string.Format("using pilot declared altitude: {0}m", altitude));
            }
            else if (!double.IsNaN(defaultAltitude))
            {
                altitude = defaultAltitude;
                AddNote(string.Format("using default altitude: {0}m", altitude));
            }
            else
            {
                altitude = QueryEarthtoolsElevation(tmpPoint);
                AddNote(string.Format("using web service ground elevation: {0}m", altitude));
            }

            return(new AXWaypoint(string.Format("D{0:00}", goal.Number), goal.Time, tmpPoint.Easting, tmpPoint.Northing, altitude));
        }
Beispiel #4
0
        private void AddDeclaredGoal_Click(object sender, RoutedEventArgs e)
        {
            GoalDeclaration declaration = null;

            if (sender is Button)
            {
                if (listBoxDeclaredGoals.SelectedItem != null)
                {
                    declaration = (GoalDeclaration)listBoxDeclaredGoals.SelectedItem;
                }
                else
                {
                    declaration = new GoalDeclaration(0, Engine.Settings.Date, "0000/0000", 0);
                }
            }
            else if (sender is MenuItem)
            {
                var point = new AXPoint(DateTime.Now, MapViewer.MousePointerPosition.X, MapViewer.MousePointerPosition.Y, 0);
                declaration = new GoalDeclaration(0, Engine.Settings.Date, point.ToString(AXPointInfo.CompetitionCoords10).Trim(), double.NaN);
            }

            if (declaration != null)
            {
                var dlg = new InputWindow(s => GoalDeclaration.Parse(s) != null)
                {
                    Title = "Enter goal declaration",
                    Text  = declaration.ToString(AXPointInfo.Name | AXPointInfo.Date | AXPointInfo.Time | AXPointInfo.Declaration | AXPointInfo.Altitude)
                };
                dlg.ShowDialog();
                if (dlg.Response == System.Windows.Forms.DialogResult.OK)
                {
                    Report.AddDeclaredGoal(GoalDeclaration.Parse(dlg.Text));
                    Engine.Display();
                }
            }
        }
Beispiel #5
0
 public void AddDeclaredGoal(GoalDeclaration declaration)
 {
     InsertIntoCollection(DeclaredGoals, declaration);
     Notes.Add(string.Format("New goal declaration {0} added by {1}", declaration, Debriefer));
     IsDirty = true;
 }