コード例 #1
0
ファイル: GisMaths.cs プロジェクト: modulexcite/TurboTrainer
        public static Tuple <double, double> DistanceWithGradient(GpxPoint first, GpxPoint last)
        {
            var distance = Distance(first, last);
            var gradient = (double)(last.Elevation - first.Elevation) / distance * 100;

            return(Tuple.Create(distance, gradient));
        }
コード例 #2
0
ファイル: GisMaths.cs プロジェクト: modulexcite/TurboTrainer
        public static Tuple<double, double> DistanceWithGradient(GpxPoint first, GpxPoint last)
        {
            var distance = Distance(first, last);
            var gradient = (double)(last.Elevation - first.Elevation) / distance * 100;

            return Tuple.Create(distance, gradient);
        }
コード例 #3
0
        public GpxSection(GpxPoint start, GpxPoint end)
        {
            this.start = start;
            this.end   = end;

            distanceWithGradient = new Lazy <Tuple <double, double> >(() => GisMaths.DistanceWithGradient(start, end));
            timeTaken            = new Lazy <TimeSpan>(() => end.Time - start.Time);
        }
コード例 #4
0
        public GpxSection(GpxPoint start, GpxPoint end)
        {
            this.start = start;
            this.end = end;

            distanceWithGradient = new Lazy<Tuple<double,double>>(() => GisMaths.DistanceWithGradient(start, end));
            timeTaken = new Lazy<TimeSpan>(() => end.Time - start.Time);
        }
コード例 #5
0
ファイル: GisMaths.cs プロジェクト: modulexcite/TurboTrainer
        private const double earthRadius = 6371000; // metres

        #endregion Fields

        #region Methods

        public static double Distance(GpxPoint first, GpxPoint last)
        {
            var dLatitude = (last.Latitude - first.Latitude).ToRadians();
            var dLongitude = (last.Longitude - first.Longitude).ToRadians();

            var startLatitude = first.Latitude.ToRadians();
            var endLatitude = last.Latitude.ToRadians();

            var a = Math.Sin(dLatitude / 2) * Math.Sin(dLatitude / 2) +
                    Math.Sin(dLongitude / 2) * Math.Sin(dLongitude / 2) *
                    Math.Cos(startLatitude) * Math.Cos(endLatitude);

            var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));

            return earthRadius * c;
        }
コード例 #6
0
ファイル: GisMaths.cs プロジェクト: modulexcite/TurboTrainer
        private const double earthRadius = 6371000; // metres

        public static double Distance(GpxPoint first, GpxPoint last)
        {
            var dLatitude  = (last.Latitude - first.Latitude).ToRadians();
            var dLongitude = (last.Longitude - first.Longitude).ToRadians();

            var startLatitude = first.Latitude.ToRadians();
            var endLatitude   = last.Latitude.ToRadians();

            var a = Math.Sin(dLatitude / 2) * Math.Sin(dLatitude / 2) +
                    Math.Sin(dLongitude / 2) * Math.Sin(dLongitude / 2) *
                    Math.Cos(startLatitude) * Math.Cos(endLatitude);

            var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));

            return(earthRadius * c);
        }
コード例 #7
0
 public static void AssertSection(this GpxSection gpxSection, GpxPoint expectedStartPoint, GpxPoint expectedEndPoint)
 {
     gpxSection.AssertSection(expectedStartPoint.Latitude, expectedStartPoint.Longitude, expectedStartPoint.Elevation, expectedStartPoint.Time.ToString(CultureInfo.InvariantCulture),
         expectedEndPoint.Latitude, expectedEndPoint.Longitude, expectedEndPoint.Elevation, expectedEndPoint.Time.ToString(CultureInfo.InvariantCulture));
 }