Beispiel #1
0
        public DataAnalyzer(List<Segment> segments, wptType startPoint = null)
        {
            TrackPoints = BuildTrackPoints(segments, startPoint);

            Segments = segments;
            Segues = BuildSegues(Segments);
        }
Beispiel #2
0
        public static double Course(wptType pt1, wptType pt2)
        {
            // convert latitude and longitude to radians
            double lat1 = DegreesToRadians((double)pt1.lat);
            double lon1 = DegreesToRadians((double)pt1.lon);
            double lat2 = DegreesToRadians((double)pt2.lat);
            double lon2 = DegreesToRadians((double)pt2.lon);

            // compute latitude and longitude differences
            double dlat = lat2 - lat1;
            double dlon = lon2 - lon1;

            double distanceNorth = dlat;
            double distanceEast = dlon * Math.Cos(lat1);

            // compute the course
            double course = Math.Atan2(distanceEast, distanceNorth) % (2 * Math.PI);
            course = RadiansToDegrees(course);
            if (course < 0)
                course += 360;

            return course;
        }
Beispiel #3
0
        public List<wptType> BuildTrackPoints(List<Segment> segments, wptType startPoint = null)
        {
            List<wptType> points = new List<wptType>();

            wptType start = startPoint ?? new wptType();
            start.name = "Point 1";
            points.Add(start);

            decimal lat = start.lat;
            decimal lon = start.lon;
            decimal ele = start.ele;
            DateTime time = start.time;

            foreach(Segment s in segments)
            {
                lat += ToDecimal(s.FlatEarthDistance * Math.Cos(s.Course));
                lon += ToDecimal(s.FlatEarthDistance * Math.Sin(s.Course));
                ele += ToDecimal(ele + ToDecimal(s.VerticalDistance));
                time += new TimeSpan(0, 0, 0, ToInt(Math.Floor(s.Time)), ToInt(1000 * (s.Time - ToInt(Math.Floor(s.Time)))));

                points.Add(new wptType { name = String.Format("Point {0}", points.Count() + 1), lat = lat, lon = lon, ele = ele, time = time });
            }

            return points;
        }
Beispiel #4
0
        public static double VerticalVelocity(wptType point1, wptType point2)
        {
            double distance = VerticalDistance(point1, point2);

            TimeSpan time = point2.time - point1.time;

            double seconds = time.TotalMilliseconds / 1000;

            return distance / seconds;
        }
Beispiel #5
0
 public static double VerticalDistance(wptType point1, wptType point2)
 {
     return (double)(point2.ele - point1.ele);
 }
Beispiel #6
0
        public static double Velocity(wptType point1, wptType point2, bool flatEarth = false)
        {
            double distance = Distance(point1, point2, flatEarth);

            TimeSpan time = point2.time - point1.time;

            double seconds = time.TotalMilliseconds / 1000;

            return distance / seconds;
        }
Beispiel #7
0
        public static double Time(wptType point1, wptType point2)
        {
            TimeSpan time = point2.time - point1.time;

            double seconds = time.TotalMilliseconds / 1000;

            return seconds;
        }
Beispiel #8
0
        public static double Distance(wptType pt1, wptType pt2, bool flatEarth = false)
        {
            // convert latitude and longitude to radians
            double lat1 = DegreesToRadians((double)pt1.lat);
            double lon1 = DegreesToRadians((double)pt1.lon);
            double lat2 = DegreesToRadians((double)pt2.lat);
            double lon2 = DegreesToRadians((double)pt2.lon);

            // compute latitude and longitude differences
            double dlat = lat2 - lat1;
            double dlon = lon2 - lon1;

            double distanceNorth = dlat;
            double distanceEast = dlon * Math.Cos(lat1);

            // and convert the radians to meters
            distanceNorth = RadiansToMeters(distanceNorth);
            distanceEast = RadiansToMeters(distanceEast);

            double distance = Distance(distanceNorth, distanceEast);

            if (!flatEarth)
            {
                // add the elevation difference to the calculation
                double vertical = (double)pt2.ele - (double)pt1.ele;
                distance = Distance(distanceNorth, distanceEast, vertical);
            }

            return distance;
        }