/// <summary> /// /// </summary> /// <returns></returns> public override string ToString() { if (Azimuth == null) { return(string.Empty); } return("S:" + Range.ToString("0.####") + ", A:" + Azimuth.ToString(Angle.DataStyle.DD_MM_SSssss)); }
/// <summary> /// Outputs the current instance as a string using the specified format and culture information. /// </summary> /// <param name="format">The format to use.-or- A null reference (Nothing in Visual Basic) to use the default format defined for the type of the <see cref="T:System.IFormattable"/> implementation.</param> /// <param name="formatProvider">The provider to use to format the value.-or- A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.</param> /// <returns>A <see cref="System.String"/> that represents this instance.</returns> public string ToString(string format, IFormatProvider formatProvider) { CultureInfo culture = (CultureInfo)formatProvider ?? CultureInfo.CurrentCulture; if (string.IsNullOrEmpty(format)) { format = "G"; } // Output as speed and bearing return(_speed.ToString(format, culture) + " " + _bearing.ToString(format, culture)); }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <param name="format">The format to use.-or- A null reference (Nothing in Visual Basic) to use the default format defined for the type of the <see cref="T:System.IFormattable"/> implementation.</param> /// <param name="formatProvider">The provider to use to format the value.-or- A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.</param> /// <returns>A <see cref="System.String"/> that represents this instance.</returns> public string ToString(string format, IFormatProvider formatProvider) { CultureInfo culture = (CultureInfo)formatProvider ?? CultureInfo.CurrentCulture; if (string.IsNullOrEmpty(format)) { format = "G"; } return(Name + " (" + _pseudorandomNumber.ToString(format, formatProvider) + "): " + _azimuth.ToString(format, formatProvider) + culture.TextInfo.ListSeparator + " " + _elevation.ToString(format, formatProvider) + culture.TextInfo.ListSeparator + " " + _signalToNoiseRatio.ToString(format, formatProvider)); }
/// <summary> /// /// </summary> /// <param name="style"></param> /// <returns></returns> public string ToString(Angle.DataStyle style) { string temp = string.Empty; if (!double.IsNaN(Range)) { temp += "R:" + Range.ToString("# ###.###"); } if (Azimuth != null) { temp += ", A:" + Azimuth.ToString(style) + ", E:" + Elevation.ToString(style); } return(temp); }
public string ToString(string format, IFormatProvider formatProvider) { CultureInfo culture = (CultureInfo)formatProvider; if (culture == null) { culture = CultureInfo.CurrentCulture; } if (format == null || format.Length == 0) { format = "G"; } return(Name + " (" + _PseudorandomNumber.ToString(format, formatProvider) + "): " + _Azimuth.ToString(format, formatProvider) + culture.TextInfo.ListSeparator + " " + _Elevation.ToString(format, formatProvider) + culture.TextInfo.ListSeparator + " " + _SignalToNoiseRatio.ToString(format, formatProvider)); }
/// <summary> /// Outputs the current instance as a string using the specified format and culture information. /// </summary> public string ToString(string format, IFormatProvider formatProvider) { CultureInfo culture = (CultureInfo)formatProvider; if (culture == null) { culture = CultureInfo.CurrentCulture; } if (format == null || format.Length == 0) { format = "G"; } // Output as speed and bearing return(_Speed.ToString(format, culture) + " " + _Bearing.ToString(format, culture)); }
public void Azimuth_Subtraction_Az340MinusAz268_equalsDeflectionPos72() { Azimuth incomingDir = Azimuth.ctorAzimuthFromDegree(268); var str = incomingDir.ToString(); Assert.AreEqual(268.0, incomingDir.getAsDegreesDouble(), 0.0000001); Azimuth outgoingDir = Azimuth.ctorAzimuthFromDegree(340); Assert.AreEqual(340.0, outgoingDir.getAsDegreesDouble(), 0.0000001); Deflection def = outgoingDir - incomingDir; Assert.AreEqual (expected: 72.0 , actual: def.getAsDegreesDouble() , delta: 0.00001); Assert.AreEqual (expected: 1 , actual: def.deflectionDirection); }
public string GenerateReport() { Recalculate(); if (String.IsNullOrEmpty(TreeStatus)) { return(string.Empty); } var azimuth = (Azimuth > 0) ? "Azimuth:" + Azimuth.ToString() : String.Empty; return(String.Format("Tree was {0} (DBH:{1}, slope:{2}%, slope distance:{3:F2}', limiting distance:{4:F2}' to {5} of tree, {6}:{7}) {8}\r\n", TreeStatus, DBH, SlopePCT, SlopeDistance, LimitingDistance, MeasureTo.ToString(), (IsVariableRadius) ? "BAF" : "FPS", BAForFPSize, azimuth)); }
/// <summary> /// Creates a GprmcSentence from the specified parameters /// </summary> /// <param name="utcDateTime"></param> /// <param name="isFixAcquired"></param> /// <param name="position"></param> /// <param name="speed"></param> /// <param name="bearing"></param> /// <param name="magneticVariation"></param> public GprmcSentence(DateTime utcDateTime, bool isFixAcquired, Position position, Speed speed, Azimuth bearing, Longitude magneticVariation) { // Use a string builder to create the sentence text StringBuilder builder = new StringBuilder(128); /* GPRMC sentences have the following format: * * $GPRMC,040302.663,A,3939.7,N,10506.6,W,0.27,358.86,200804,,*1A */ // Append the command word, $GPRMC builder.Append("$GPRMC"); // Append a comma builder.Append(','); #region Append the UTC time builder.Append(utcDateTime.Hour.ToString("0#", NmeaCultureInfo)); builder.Append(utcDateTime.Minute.ToString("0#", NmeaCultureInfo)); builder.Append(utcDateTime.Second.ToString("0#", NmeaCultureInfo)); builder.Append("."); builder.Append(utcDateTime.Millisecond.ToString("00#", NmeaCultureInfo)); #endregion // Append a comma builder.Append(','); #region Append the fix status // Write fix information if (isFixAcquired) builder.Append("A"); else builder.Append("V"); #endregion // Append a comma builder.Append(','); #region Append the position // Append latitude in the format HHMM.MMMM. builder.Append(position.Latitude.ToString("HHMM.MMMM,I,", NmeaCultureInfo)); // Append Longitude in the format HHHMM.MMMM. builder.Append(position.Longitude.ToString("HHHMM.MMMM,I,", NmeaCultureInfo)); #endregion // Append the speed (in knots) builder.Append(speed.ToKnots().ToString("v.v", NmeaCultureInfo)); // Append a comma builder.Append(','); // Append the bearing builder.Append(bearing.ToString("d.d", NmeaCultureInfo)); // Append a comma builder.Append(','); #region Append the UTC date // Append UTC date builder.Append(utcDateTime.Day.ToString("0#", NmeaCultureInfo)); builder.Append(utcDateTime.Month.ToString("0#", NmeaCultureInfo)); // Append the year (year minus 2000) int year = utcDateTime.Year - 2000; builder.Append(year.ToString("0#", NmeaCultureInfo)); #endregion // Append a comma builder.Append(','); // Append magnetic variation builder.Append(magneticVariation.ToString("d.d", NmeaCultureInfo)); // Set this object's sentence SetSentence(builder.ToString()); // Finally, append the checksum AppendChecksum(); }
/// <summary> /// Creates a GprmcSentence from the specified parameters. /// </summary> /// <param name="utcDateTime">The UTC date time.</param> /// <param name="isFixAcquired">if set to <c>true</c> [is fix acquired].</param> /// <param name="position">The position.</param> /// <param name="speed">The speed.</param> /// <param name="bearing">The bearing.</param> /// <param name="magneticVariation">The magnetic variation.</param> public GprmcSentence(DateTime utcDateTime, bool isFixAcquired, Position position, Speed speed, Azimuth bearing, Longitude magneticVariation) { // Use a string builder to create the sentence text StringBuilder builder = new(128); /* GPRMC sentences have the following format: * * $GPRMC, 040302.663, A, 3939.7, N, 10506.6, W, 0.27, 358.86, 200804, ,*1A */ // Append the command word, $GPRMC builder.Append("$GPRMC"); builder.Append(','); // Append the UTC time builder.Append(utcDateTime.Hour.ToString("0#", NmeaCultureInfo)); builder.Append(utcDateTime.Minute.ToString("0#", NmeaCultureInfo)); builder.Append(utcDateTime.Second.ToString("0#", NmeaCultureInfo)); builder.Append("."); builder.Append(utcDateTime.Millisecond.ToString("00#", NmeaCultureInfo)); builder.Append(','); // Write fix information builder.Append(isFixAcquired ? "A" : "V"); builder.Append(','); // Append the position // Append latitude in the format HHMM.MMMM. builder.Append(position.Latitude.ToString(LatitudeFormat, NmeaCultureInfo)); // Append Longitude in the format HHHMM.MMMM. builder.Append(position.Longitude.ToString(LongitudeFormat, NmeaCultureInfo)); // Append the speed (in knots) builder.Append(speed.ToKnots().ToString("v.v", NmeaCultureInfo)); builder.Append(','); // Append the bearing builder.Append(bearing.ToString("d.d", NmeaCultureInfo)); builder.Append(','); // Append UTC date builder.Append(utcDateTime.Day.ToString("0#", NmeaCultureInfo)); builder.Append(utcDateTime.Month.ToString("0#", NmeaCultureInfo)); // Append the year (year minus 2000) int year = utcDateTime.Year - 2000; builder.Append(year.ToString("0#", NmeaCultureInfo)); builder.Append(','); // Append magnetic variation builder.Append(Math.Abs(magneticVariation.DecimalDegrees).ToString("0.0", NmeaCultureInfo)); builder.Append(","); builder.Append(magneticVariation.Hemisphere == LongitudeHemisphere.West ? "W" : "E"); // Set this object's sentence Sentence = builder.ToString(); SetPropertiesFromSentence(); // correct this classes properties based on the sentence // Finally, append the checksum AppendChecksum(); }
public GprmcSentence(DateTime utcDateTime, bool isFixAcquired, Position position, Speed speed, Azimuth bearing, Longitude magneticVariation) { // Use a string builder to create the sentence text StringBuilder builder = new StringBuilder(128); /* GPRMC sentences have the following format: * * $GPRMC,040302.663,A,3939.7,N,10506.6,W,0.27,358.86,200804,,*1A */ // Append the command word, $GPRMC builder.Append("$GPRMC"); // Append a comma builder.Append(','); #region Append the UTC time builder.Append(utcDateTime.Hour.ToString("0#", NmeaCultureInfo)); builder.Append(utcDateTime.Minute.ToString("0#", NmeaCultureInfo)); builder.Append(utcDateTime.Second.ToString("0#", NmeaCultureInfo)); builder.Append("."); builder.Append(utcDateTime.Millisecond.ToString("00#", NmeaCultureInfo)); #endregion // Append a comma builder.Append(','); #region Append the fix status // Write fix information if (isFixAcquired) { builder.Append("A"); } else { builder.Append("V"); } #endregion // Append a comma builder.Append(','); #region Append the position // Append latitude in the format HHMM.MMMM. builder.Append(position.Latitude.ToString("HHMM.MMMM,I,", NmeaCultureInfo)); // Append Longitude in the format HHHMM.MMMM. builder.Append(position.Longitude.ToString("HHHMM.MMMM,I,", NmeaCultureInfo)); #endregion // Append the speed (in knots) builder.Append(speed.ToKnots().ToString("v.v", NmeaCultureInfo)); // Append a comma builder.Append(','); // Append the bearing builder.Append(bearing.ToString("d.d", NmeaCultureInfo)); // Append a comma builder.Append(','); #region Append the UTC date // Append UTC date builder.Append(utcDateTime.Day.ToString("0#", NmeaCultureInfo)); builder.Append(utcDateTime.Month.ToString("0#", NmeaCultureInfo)); // Append the year (year minus 2000) int year = utcDateTime.Year - 2000; builder.Append(year.ToString("0#", NmeaCultureInfo)); #endregion // Append a comma builder.Append(','); // Append magnetic variation builder.Append(magneticVariation.ToString("d.d", NmeaCultureInfo)); // Set this object's sentence SetSentence(builder.ToString()); // Finally, append the checksum AppendChecksum(); }
public override string ToString() { return(string.Format("Alt/Az = {0}/{1}", Altitude.ToString(AngularFormat.DegreesMinutesSeconds, false), Azimuth.ToString(AngularFormat.DegreesMinutesSeconds, false))); }