/// <summary> /// Check if the declared goal is conform to the distance rules to other goals /// <para>will not check against itself</para> /// </summary> /// <param name="declaredGoal">the declared goal to be checked</param> /// <returns>true: is conform; false: is not conform</returns> public bool CheckConformance(DeclaredGoal declaredGoal) { bool isConform = true; foreach (DeclaredGoal otherGoal in DeclaredGoals) { if (declaredGoal.Equals(otherGoal)) { continue; } double distanceBetweenPositionOfDeclarationAndDeclaredGoal = CoordinateHelpers.Calculate2DDistance(declaredGoal.GoalDeclared, otherGoal.GoalDeclared); if (!double.IsNaN(MinimumDistance)) { if (distanceBetweenPositionOfDeclarationAndDeclaredGoal < MinimumDistance) { isConform = false; break; } } if (!double.IsNaN(MaximumDistance)) { if (distanceBetweenPositionOfDeclarationAndDeclaredGoal > MaximumDistance) { isConform = false; break; } } } return(isConform); }
/// <summary> /// Check if the declared goal is conform to the height difference rules /// </summary> /// <param name="declaredGoal">the declared goal to be checked</param> /// <returns>true: is conform; false: is not conform</returns> public bool CheckConformance(DeclaredGoal declaredGoal) { bool isConform = true; double heightDifferenceBetweenPositionOfDeclarationAndDeclaredGoal; if (UseGPSAltitude) { heightDifferenceBetweenPositionOfDeclarationAndDeclaredGoal = declaredGoal.PositionAtDeclaration.AltitudeGPS - declaredGoal.GoalDeclared.AltitudeGPS; } else { heightDifferenceBetweenPositionOfDeclarationAndDeclaredGoal = declaredGoal.PositionAtDeclaration.AltitudeBarometric - declaredGoal.GoalDeclared.AltitudeBarometric; } if (!double.IsNaN(MinimumHeightDifference)) { if (heightDifferenceBetweenPositionOfDeclarationAndDeclaredGoal < MinimumHeightDifference) { isConform = false; } } if (!double.IsNaN(MaximumHeightDifference)) { if (heightDifferenceBetweenPositionOfDeclarationAndDeclaredGoal > MaximumHeightDifference) { isConform = false; } } return(isConform); }
/// <summary> /// Calculate the 2d distance traveled in the pie tier times the multiplier /// </summary> /// <param name="track">the track to be used</param> /// <param name="useGPSAltitude">true: use GPS altitude;false: use barometric altitude</param> /// <param name="result">the 2D distance in the pie tier times the multiplier</param> /// <returns>true:success;false:error</returns> public bool CalculateTierResult(Track track, bool useGPSAltitude, out double result) { string functionErrorMessage = $"Failed to calculate result for {this} and Pilot '#{track.Pilot.PilotNumber}{(!string.IsNullOrWhiteSpace(track.Pilot.FirstName) ? $"({track.Pilot.FirstName},{track.Pilot.LastName})" : "")}': "; result = 0.0; List <(int, Coordinate)> trackPointsInDonut = new List <(int trackPointNumber, Coordinate coordinate)>(); DeclaredGoal targetGoal = ValidationHelper.GetValidGoal(track, GoalNumber, DeclarationValidationRules); if (targetGoal == null) { //Debug.WriteLine("No valid goal found"); Log(LogSeverityType.Error, functionErrorMessage + $"No valid goal found for goal '#{GoalNumber}'"); return(false); } List <Coordinate> coordinates = track.TrackPoints; if (!double.IsNaN(LowerBoundary)) { if (useGPSAltitude) { coordinates = coordinates.Where(x => x.AltitudeGPS >= LowerBoundary).ToList();//take all point above lower boundary } else { coordinates = coordinates.Where(x => x.AltitudeBarometric >= LowerBoundary).ToList();//take all point above lower boundary } } if (!double.IsNaN(UpperBoundary)) { if (useGPSAltitude) { coordinates = coordinates.Where(x => x.AltitudeGPS <= UpperBoundary).ToList();//take all points below upper boundary } else { coordinates = coordinates.Where(x => x.AltitudeBarometric <= UpperBoundary).ToList();//take all points below upper boundary } } for (int index = 0; index < coordinates.Count; index++) { double distanceToGoal = CoordinateHelpers.Calculate2DDistance(coordinates[index], targetGoal.GoalDeclared); //calculate distance to goal if (distanceToGoal <= Radius) //save all trackpoints within the radius { trackPointsInDonut.Add((index, coordinates[index]));
/// <summary> /// Check if the declared goal is conform to the distance rules /// </summary> /// <param name="declaredGoal">the declared goal to be checked</param> /// <returns>true: is conform; false: is not conform</returns> public bool CheckConformance(DeclaredGoal declaredGoal) { bool isConform = true; double distanceBetweenPositionOfDeclarationAndDeclaredGoal = CoordinateHelpers.Calculate2DDistance(declaredGoal.PositionAtDeclaration, declaredGoal.GoalDeclared); if (!double.IsNaN(MinimumDistance)) { if (distanceBetweenPositionOfDeclarationAndDeclaredGoal < MinimumDistance) { isConform = false; } } if (!double.IsNaN(MaximumDistance)) { if (distanceBetweenPositionOfDeclarationAndDeclaredGoal > MaximumDistance) { isConform = false; } } return(isConform); }