コード例 #1
0
ファイル: GpsPosition.cs プロジェクト: mendhak/gpstracka
 /// <summary>Calculates distance of two positions in given unit</summary>
 /// <param name="pos1">A position</param>
 /// <param name="pos2">A position</param>
 /// <param name="unit">The unit to get result in</param>
 /// <returns>Distance between given points in given unit; 0 if <paramref name="unit"/> is not one of the <see cref="OpenNETCF.IO.Serial.GPS.Units"/> values.</returns>
 /// <exception cref="ArgumentException"><see cref="Latitude"/> or <paramref name="Longitude"/> of <paramref name="pos1"/> or <paramref name="pos2"/> is null.</exception>
 public static decimal CalculateDistance(GpsPosition pos1, GpsPosition pos2, OpenNETCF.IO.Serial.GPS.Units unit)
 {
     if (!pos1.Longitude.HasValue || !pos1.Latitude.HasValue) throw new ArgumentException(GPSTracka.Properties.Resources.err_PositionIsNull, "pos1");
     if (!pos2.Longitude.HasValue || !pos2.Latitude.HasValue) throw new ArgumentException(GPSTracka.Properties.Resources.err_PositionIsNull, "pos2");
     var ret = GpsPoint.CalculateDistance(new GpsPoint(pos1.Latitude.Value, pos1.Longitude.Value, pos1.Altitude), new GpsPoint(pos2.Latitude.Value, pos1.Longitude.Value, pos2.Altitude));
     switch (unit)
     {
         case OpenNETCF.IO.Serial.GPS.Units.Kilometers: return ret;
         case OpenNETCF.IO.Serial.GPS.Units.Knots: return ret / 1.85200m;
         case OpenNETCF.IO.Serial.GPS.Units.Miles: return ret / 1.609344m;
         default: throw new ArgumentException("Invalid enum argument");
     }
 }
コード例 #2
0
        /// <summary>Calculates distance of two positions in given unit</summary>
        /// <param name="pos1">A position</param>
        /// <param name="pos2">A position</param>
        /// <param name="unit">The unit to get result in</param>
        /// <returns>Distance between given points in given unit; 0 if <paramref name="unit"/> is not one of the <see cref="OpenNETCF.IO.Serial.GPS.Units"/> values.</returns>
        /// <exception cref="ArgumentException"><see cref="Latitude"/> or <paramref name="Longitude"/> of <paramref name="pos1"/> or <paramref name="pos2"/> is null.</exception>
        public static decimal CalculateDistance(GpsPosition pos1, GpsPosition pos2, OpenNETCF.IO.Serial.GPS.Units unit)
        {
            if (!pos1.Longitude.HasValue || !pos1.Latitude.HasValue)
            {
                throw new ArgumentException(GPSTracka.Properties.Resources.err_PositionIsNull, "pos1");
            }
            if (!pos2.Longitude.HasValue || !pos2.Latitude.HasValue)
            {
                throw new ArgumentException(GPSTracka.Properties.Resources.err_PositionIsNull, "pos2");
            }
            var ret = GpsPoint.CalculateDistance(new GpsPoint(pos1.Latitude.Value, pos1.Longitude.Value, pos1.Altitude), new GpsPoint(pos2.Latitude.Value, pos1.Longitude.Value, pos2.Altitude));

            switch (unit)
            {
            case OpenNETCF.IO.Serial.GPS.Units.Kilometers: return(ret);

            case OpenNETCF.IO.Serial.GPS.Units.Knots: return(ret / 1.85200m);

            case OpenNETCF.IO.Serial.GPS.Units.Miles: return(ret / 1.609344m);

            default: throw new ArgumentException("Invalid enum argument");
            }
        }
コード例 #3
0
 /// <summary>CTor</summary>
 /// <param name="position">Current GPS posotion</param>
 public GpsPositionEventArgs(GpsPosition position)
 {
     this.position = position;
 }
コード例 #4
0
ファイル: GpsProvider.cs プロジェクト: mendhak/gpstracka
 /// <summary>CTor</summary>
 /// <param name="position">Current GPS posotion</param>
 public GpsPositionEventArgs(GpsPosition position)
 {
     this.position = position;
 }