Esempio n. 1
0
 /// <summary>Calculates distance of two positions in km</summary>
 /// <param name="pos1">A position</param>
 /// <param name="pos2">A position</param>
 /// <returns>Distance between given points in km.</returns>
 public static decimal CalculateDistance(GpsPoint pos1, GpsPoint pos2)
 {
     /*double num = ((double)pos2.Latitude - (double)pos1.Latitude) * (Math.PI / 180.0);
      * double num2 = ((double)pos2.Longitude - (double)pos1.Longitude) * (Math.PI * 180.0);
      * double a = (Math.Sin(num / 2.0) * Math.Sin(num / 2.0)) + (((Math.Cos((double)pos1.Latitude * (Math.PI / 180.0)) * Math.Cos((double)pos2.Latitude * (Math.PI * 180.0))) * Math.Sin(num2 / 2.0)) * Math.Sin(num2 / 2.0));
      * if (a < 0) return 0;
      * double num4 = 2.0 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1.0 - a));
      * return (decimal)(6371 * num4);*/
     return((decimal)Calc((double)pos1.Latitude, (double)pos1.Longitude, (double)pos2.Latitude, (double)pos2.Longitude));
 }
Esempio n. 2
0
            public GpsStatistics(TrackerForm form, DateTime startTime, GpsPoint startPosition)
            {
                if (form == null)
                {
                    throw new ArgumentNullException("form");
                }

                StartTime = CurrentTime = startTime;
                startPos  = CurrentPos = startPosition;
                this.form = form;
                ShowValues(ValueKind.All);
            }
Esempio n. 3
0
            public GpsStatistics(TrackerForm form, DateTime startTime, GpsPoint startPosition)
            {
                if (form == null)
                {
                    throw new ArgumentNullException("form");
                }

                StartTime = CurrentTime = startTime;
                startPos = CurrentPos = startPosition;
                this.form = form;
                ShowValues(ValueKind.All);
            }
Esempio n. 4
0
        /// <summary>Called when point is nearly logged</summary>
        /// <param name="time">Logged time</param>
        /// <param name="gpsPoint">Actual position</param>
        /// <param name="logThisPoint">true when point was logged false when it was not</param>
        private void OnPoint(DateTime time, GpsPoint gpsPoint, bool logThisPoint)
        {
            if (continuing && statistic != null)
            {
                statistic.PauseTime = statistic.PauseTime + (time - lastLoggedPointTime);
                //User pause
            }

            if (statistic == null)
            {//Initialize
                statistic = new GpsStatistics(this, time, gpsPoint);
                lastKnownElevation = gpsPoint.Altitude;
                lastLoggedPointTime = time;
                return;
            }
            statistic.CurrentTime = time;

            if (logThisPoint)
            {//This point is logged, count it
                decimal delta = gpsPoint - statistic.CurrentPos;//km
                statistic.SumLength = statistic.SumLength + delta;
                statistic.CurrentPos = gpsPoint;
                statistic.PointsTotal++;
            }
            else
            {//This point is not logged, pause
                statistic.PauseTime = statistic.PauseTime + (time - lastLoggedPointTime);
            }
            lastLoggedPointTime = time;

            if (lastKnownElevation == null)
            {//Initialize altitude if necessary
                lastKnownElevation = gpsPoint.Altitude;
                return;
            }

            if (logThisPoint && gpsPoint.Altitude.HasValue)
            {//Elevation
                decimal delta = gpsPoint.Altitude.Value - lastKnownElevation.Value;
                if (delta < 0)
                {
                    statistic.SumEleMinus = statistic.SumEleMinus - delta;
                }
                else
                {
                    statistic.SumElePlus = statistic.SumElePlus + delta;
                }
                lastKnownElevation = gpsPoint.Altitude;
            }
        }
Esempio n. 5
0
 /// <summary>Calculates distance of two positions in km</summary>
 /// <param name="pos1">A position</param>
 /// <param name="pos2">A position</param>
 /// <returns>Distance between given points in km.</returns>
 public static decimal CalculateDistance(GpsPoint pos1, GpsPoint pos2)
 {
     /*double num = ((double)pos2.Latitude - (double)pos1.Latitude) * (Math.PI / 180.0);
     double num2 = ((double)pos2.Longitude - (double)pos1.Longitude) * (Math.PI * 180.0);
     double a = (Math.Sin(num / 2.0) * Math.Sin(num / 2.0)) + (((Math.Cos((double)pos1.Latitude * (Math.PI / 180.0)) * Math.Cos((double)pos2.Latitude * (Math.PI * 180.0))) * Math.Sin(num2 / 2.0)) * Math.Sin(num2 / 2.0));
     if (a < 0) return 0;
     double num4 = 2.0 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1.0 - a));
     return (decimal)(6371 * num4);*/
     return (decimal)Calc((double)pos1.Latitude, (double)pos1.Longitude, (double)pos2.Latitude, (double)pos2.Longitude);
 }