Esempio n. 1
0
        void PaintProfile2(PaintEventArgs e)
        {
            List <GpsLocation> lst;

            if (elevationProfileNew == null)
            {
                return;
            }

            var pen = new Pen(Brushes.Black, 3);

            var data = elevationProfileNew.GetData();

            for (ushort i = 0; i < 360; i++)
            {
                var thisAngle = elevationProfileNew.GetData(i);
                var prevAngle = elevationProfileNew.GetData(i - 1);

                if (thisAngle != null && prevAngle != null)
                {
                    foreach (var point in thisAngle.GetPoints())
                    {
                        foreach (var otherPoint in prevAngle.GetPoints())
                        {
                            if (Math.Abs(point.Distance.Value - otherPoint.Distance.Value) < point.Distance / _minDist)
                            {
                                var b1 = GpsUtils.Normalize360(point.Bearing.Value - _heading);
                                var x1 = GpsUtils.Normalize360(b1 + 35) * DG_WIDTH;
                                var y1 = 250 - point.VerticalViewAngle.Value * 40;

                                var b2 = GpsUtils.Normalize360(otherPoint.Bearing.Value - _heading);
                                var x2 = GpsUtils.Normalize360(b2 + 35) * DG_WIDTH;
                                var y2 = 250 - otherPoint.VerticalViewAngle.Value * 40;
                                if (Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2)) < 100)
                                {
                                    e.Graphics.DrawLine(pen, (float)x1, (float)y1, (float)x2, (float)y2);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        void PaintTerrain(PaintEventArgs e)
        {
            var pen        = new Pen(Brushes.Black, 20);
            var _data2     = new List <GpsLocation>();
            var sortedData = _data
                             .Where(i =>
                                    i.Distance > MIN_DISTANCE && i.Distance < _visibility * 1000 &&
                                    GpsUtils.IsAngleBetween(i.Bearing.Value, _heading, 35))
                             .OrderByDescending(i2 => i2.Distance);

            foreach (var point in sortedData)
            {
                var b = GpsUtils.Normalize360(point.Bearing.Value - _heading);
                var c = (point.Distance / (_visibility * 1000)) * 200;
                pen.Color = Color.FromArgb(100, (int)c, (int)c, (int)c);
                var x = GpsUtils.Normalize360(b + 35) * DG_WIDTH;
                var y = 250 - point.VerticalViewAngle * 40;
                e.Graphics.DrawLine(pen, (float)x, (float)500, (float)x, (float)y);
            }
            var z = _data
                    .Where(i => i.Distance > MIN_DISTANCE && i.Distance < _visibility * 1000)
                    .GroupBy(i => Math.Floor(i.Bearing.Value));

            foreach (var i in z)
            {
                var bearing = i.Key;
                var points  = i.OrderBy(i2 => i2.Distance);
                List <GpsLocation> displayedPoints = new List <GpsLocation>();
                foreach (var point in points)
                {
                    bool display = true;
                    foreach (var poi in displayedPoints)
                    {
                        if (point.VerticalViewAngle < poi.VerticalViewAngle)
                        {
                            display = false;
                            break;
                        }
                    }
                    if (display || displayedPoints.Count == 0)
                    {
                        displayedPoints.Add(point);
                    }
                }

                displayedPoints.OrderByDescending(j => j.Distance);

                foreach (var point in displayedPoints)
                {
                    bool display = true;
                    foreach (var otherPoint in displayedPoints)
                    {
                        if (point.Altitude < otherPoint.Altitude && Math.Abs(point.Distance.Value - otherPoint.Distance.Value) < 500)
                        {
                            display = false;
                        }
                    }

                    if (display)
                    {
                        _data2.Add(point);
                    }
                }
            }

            //foreach (var point in sortedData)
            //{
            //    var b = GeoPoint.Normalize360(point.Bearing - _heading);
            //    var c = (point.Distance / (_visibility * 1000)) * 200;
            //    pen.Color = Color.FromArgb(100, (int)c, (int)c, (int)c);
            //    var x = GeoPoint.Normalize360(b + 35) * DG_WIDTH;
            //    var y = 250 - point.VerticalAngle * 40;
            //    if (IsMax(point))
            //    {
            //        e.Graphics.DrawLine(pen, (float)x, (float)y-10, (float)x, (float)y);
            //    }

            //}
        }
Esempio n. 3
0
 public ElevationData GetData(int angle)
 {
     return(elevationData.SingleOrDefault(i => i.Angle == GpsUtils.Normalize360(angle)));
 }