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


C# Distance.ToMeters方法代码示例

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


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

示例1: TestConvertion

        public void TestConvertion()
        {
            // Create an object with 5 m
            Distance dist = new Distance(5, DistanceUnit.Meters);

            Assert.AreEqual(5, dist.Value);
            Assert.AreEqual(DistanceUnit.Meters, dist.Units);

            Distance feet = dist.ToFeet();
            Assert.AreEqual(16.4041995, feet.Value, 0.00001);
            Assert.AreEqual(DistanceUnit.Feet, feet.Units);

            Distance meters = dist.ToMeters();
            Assert.AreEqual(5, meters.Value);
            Assert.AreEqual(DistanceUnit.Meters, meters.Units);

            Distance mm = dist.ToMillimeters();
            Assert.AreEqual(5000, mm.Value);
            Assert.AreEqual(DistanceUnit.Millimeters, mm.Units);

            Distance cm = dist.ToCentimeters();
            Assert.AreEqual(500, cm.Value);
            Assert.AreEqual(DistanceUnit.Centimeters, cm.Units);

            Distance inch = dist.ToInches();
            Assert.AreEqual(196.850394, inch.Value, 0.00001);
            Assert.AreEqual(DistanceUnit.Inches, inch.Units);

            Distance km = dist.ToKilometers();
            Assert.AreEqual(0.005, km.Value);
            Assert.AreEqual(DistanceUnit.Kilometers, km.Units);

            Distance miles = dist.ToStatuteMiles();
            Assert.AreEqual(0.00310685596, miles.Value, 0.00001);
            Assert.AreEqual(DistanceUnit.StatuteMiles, miles.Units);

            Distance nm = dist.ToNauticalMiles();
            Assert.AreEqual(0.00269978402, nm.Value, 0.00001);
            Assert.AreEqual(DistanceUnit.NauticalMiles, nm.Units);
        }
开发者ID:rowetechinc,项目名称:RTI,代码行数:40,代码来源:DistanceTest.cs

示例2: GpggaSentence

        public GpggaSentence(TimeSpan utcTime, Position position, FixQuality fixQuality, int trackedSatelliteCount,
                            DilutionOfPrecision horizontalDilutionOfPrecision, Distance altitude, Distance geoidalSeparation,
                            TimeSpan differentialGpsAge, int differentialGpsStationID)
        {        
            // Use a string builder to create the sentence text
            StringBuilder builder = new StringBuilder(128);

            #region Append the command word

            // Append the command word
            builder.Append("$GPGGA");

            #endregion

            // Append a comma
            builder.Append(',');

            #region Append the UTC time

            /* Convert UTC time to a string in the form HHMMSS.SSSS. Any value less than 10 will be
             * padded with a zero.
             */

            builder.Append(_UtcTime.Hours.ToString("0#", NmeaCultureInfo));
            builder.Append(_UtcTime.Minutes.ToString("0#", NmeaCultureInfo));
            builder.Append(_UtcTime.Seconds.ToString("0#", NmeaCultureInfo));
            builder.Append(".");
            builder.Append(_UtcTime.Milliseconds.ToString("00#", NmeaCultureInfo));

            #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

            #region Append fix quality

            switch (fixQuality)
            {
                case FixQuality.NoFix:
                    builder.Append("0");
                    break;
                case FixQuality.GpsFix:
                    builder.Append("1");
                    break;
                case FixQuality.DifferentialGpsFix:
                    builder.Append("2");
                    break;
                case FixQuality.PulsePerSecond:
                    builder.Append("3");
                    break;
                case FixQuality.FixedRealTimeKinematic:
                    builder.Append("4");
                    break;
                case FixQuality.FloatRealTimeKinematic:
                    builder.Append("5");
                    break;
                case FixQuality.Estimated:
                    builder.Append("6");
                    break;
                case FixQuality.ManualInput:
                    builder.Append("7");
                    break;
                case FixQuality.Simulated:
                    builder.Append("8");
                    break;              
            }

            #endregion

            // Append a comma
            builder.Append(",");

            // Append the tracked (signal strength is > 0) satellite count
            builder.Append(trackedSatelliteCount.ToString(NmeaCultureInfo));

            // Append a comma
            builder.Append(",");

            // Append the numerical value of HDOP
            builder.Append(horizontalDilutionOfPrecision.Value.ToString(NmeaCultureInfo));

            // Append a comma
            builder.Append(",");

            #region Altitude above sea level

            // Append the numerical value in meters
            builder.Append(altitude.ToMeters().Value.ToString(NmeaCultureInfo));

            // Append a comma, the unit (M = meters), and another comma
            builder.Append(",M,"); 
//.........这里部分代码省略.........
开发者ID:chinnisuraj1984,项目名称:navigational,代码行数:101,代码来源:GpggaSentence.cs

示例3: ConvertToMetersWorksCorrectly

        public void ConvertToMetersWorksCorrectly()
        {
            // Arrange
            const double Millimeters = 112345;
            const double Meters = 112.345;

            // Act
            var distance = new Distance(Millimeters);

            // Assert
            Assert.IsNotNull(distance);
            Assert.AreEqual(Meters, distance.ToMeters());
        }
开发者ID:kwilson,项目名称:dotnet-distance,代码行数:13,代码来源:MetricTests.cs


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