Esempio n. 1
0
        /// <summary>
        /// Presents this message as output
        /// </summary>
        public override string ToNmeaParameterList()
        {
            if (Valid)
            {
                StringBuilder     b = new StringBuilder();
                double?           degrees;
                CardinalDirection?direction;
                (degrees, direction) = RecommendedMinimumNavigationInformation.DegreesToNmea0183(Position.Latitude, true);
                if (degrees.HasValue && direction.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:0000.00000},{1},", degrees.Value, (char)direction);
                }
                else
                {
                    b.Append(",,");
                }

                (degrees, direction) = RecommendedMinimumNavigationInformation.DegreesToNmea0183(Position.Longitude, false);
                if (degrees.HasValue && direction.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:00000.00000},{1},", degrees.Value, (char)direction);
                }
                else
                {
                    b.Append(",,");
                }

                b.Append(Name);
                return(b.ToString());
            }

            return(string.Empty);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public override string ToNmeaParameterList()
        {
            if (Valid)
            {
                StringBuilder b = new StringBuilder(256);

                string time = DateTime.ToString("HHmmss.fff", CultureInfo.InvariantCulture);
                b.Append(time + ",");
                double?           degrees;
                CardinalDirection?direction;
                (degrees, direction) = RecommendedMinimumNavigationInformation.DegreesToNmea0183(NextWayPoint.Latitude, true);
                if (degrees.HasValue && direction.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:0000.00000},{1},", degrees.Value, (char)direction);
                }
                else
                {
                    b.Append(",,");
                }

                (degrees, direction) = RecommendedMinimumNavigationInformation.DegreesToNmea0183(NextWayPoint.Longitude, false);
                if (degrees.HasValue && direction.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:00000.00000},{1},", degrees.Value, (char)direction);
                }
                else
                {
                    b.Append(",,");
                }

                if (BearingTrueToWayPoint.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:F1},T,", BearingTrueToWayPoint.Value.Normalize(true).Degrees);
                }
                else
                {
                    b.Append(",T,");
                }

                if (BearingMagneticToWayPoint.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:F1},M,", BearingMagneticToWayPoint.Value.Normalize(true).Degrees);
                }
                else
                {
                    b.Append(",M,");
                }

                if (DistanceToWayPoint.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:F3},N,", DistanceToWayPoint.Value.NauticalMiles);
                }
                else
                {
                    b.Append(",N,");
                }

                b.AppendFormat(CultureInfo.InvariantCulture, "{0},D", NextWayPointName);

                return(b.ToString());
            }

            return(string.Empty);
        }
Esempio n. 3
0
        /// <inheritdoc />
        public override string ToNmeaParameterList()
        {
            if (Valid)
            {
                StringBuilder b = new StringBuilder(256);
                b.Append("A,"); // Status = Valid
                if (CrossTrackError >= Length.Zero)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:F3},L,", CrossTrackError.NauticalMiles);
                }
                else
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:F3},R,", -CrossTrackError.NauticalMiles);
                }

                b.AppendFormat(CultureInfo.InvariantCulture, "{0},{1},", PreviousWayPointName, NextWayPointName);

                double?           degrees   = null;
                CardinalDirection?direction = null;
                if (NextWayPoint != null)
                {
                    (degrees, direction) =
                        RecommendedMinimumNavigationInformation.DegreesToNmea0183(NextWayPoint.Latitude, true);
                }

                if (degrees.HasValue && direction.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:0000.00000},{1},", degrees.Value, (char)direction);
                }
                else
                {
                    b.Append(",,");
                }

                degrees   = null;
                direction = null;
                if (NextWayPoint != null)
                {
                    (degrees, direction) =
                        RecommendedMinimumNavigationInformation.DegreesToNmea0183(NextWayPoint.Longitude, false);
                }

                if (degrees.HasValue && direction.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:00000.00000},{1},", degrees.Value, (char)direction);
                }
                else
                {
                    b.Append(",,");
                }

                if (DistanceToWayPoint.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:F3},", DistanceToWayPoint.Value.NauticalMiles);
                }
                else
                {
                    b.Append(",");
                }

                if (BearingToWayPoint.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:F1},", BearingToWayPoint.Value.Normalize(true).Degrees);
                }
                else
                {
                    b.Append(",");
                }

                if (ApproachSpeed.HasValue)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "{0:F1},", ApproachSpeed.Value.Knots);
                }
                else
                {
                    b.Append(",");
                }

                if (Arrived)
                {
                    // Not sure what the final D means here. My receiver sends it, but it is not documented.
                    b.Append("A,D");
                }
                else
                {
                    b.Append("V,D");
                }

                return(b.ToString());
            }

            return(string.Empty);
        }