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)); }
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); }
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); }
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); }
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; }
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); }
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)); }