当前位置: 首页>>代码示例>>C#>>正文


C# Speed.ToKnots方法代码示例

本文整理汇总了C#中Speed.ToKnots方法的典型用法代码示例。如果您正苦于以下问题:C# Speed.ToKnots方法的具体用法?C# Speed.ToKnots怎么用?C# Speed.ToKnots使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Speed的用法示例。


在下文中一共展示了Speed.ToKnots方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GprmcSentence

        /// <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();
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:96,代码来源:GprmcSentence.cs

示例2: TestConvertion

        public void TestConvertion()
        {
            Speed speed = new Speed(5, SpeedUnit.MetersPerSecond);

            Assert.AreEqual(5, speed.Value);

            Speed ftps = speed.ToFeetPerSecond();
            Assert.AreEqual(16.40419, ftps.Value, 0.00001);
            Assert.AreEqual(SpeedUnit.FeetPerSecond, ftps.Units);

            Speed kph = speed.ToKilometersPerHour();
            Assert.AreEqual(18, kph.Value);
            Assert.AreEqual(SpeedUnit.KilometersPerHour, kph.Units);

            Speed kps = speed.ToKilometersPerSecond();
            Assert.AreEqual(0.005, kps.Value, 0.001);
            Assert.AreEqual(SpeedUnit.KilometersPerSecond, kps.Units);

            Speed knots = speed.ToKnots();
            Assert.AreEqual(9.71922246, knots.Value, 0.00001);
            Assert.AreEqual(SpeedUnit.Knots, knots.Units);

            Speed meterps = speed.ToMetersPerSecond();
            Assert.AreEqual(5, meterps.Value);
            Assert.AreEqual(SpeedUnit.MetersPerSecond, meterps.Units);

            Speed mmps = speed.ToMillimetersPerSecond();
            Assert.AreEqual(5000, mmps.Value);
            Assert.AreEqual(SpeedUnit.MillimetersPerSecond, mmps.Units);

            Speed mph = speed.ToStatuteMilesPerHour();
            Assert.AreEqual(11.1846815, mph.Value, 0.00001);
            Assert.AreEqual(SpeedUnit.StatuteMilesPerHour, mph.Units);
        }
开发者ID:Bobfrat,项目名称:RTI,代码行数:34,代码来源:SpeedTest.cs


注:本文中的Speed.ToKnots方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。