コード例 #1
0
        public void GenerateElevationProfile3(GpsLocation myLocation, double visibility, ElevationProfileData elevationData, Action <int> onProgressChange)
        {
            _elevationProfileData = new ElevationProfileData(myLocation, visibility);

            int progress = 0;

            foreach (var group in elevationData.GetData())
            {
                progress++;
                onProgressChange(progress);

                var points = group.GetPoints()
                             .Where(i => i.Distance > MIN_DISTANCE && i.Distance < visibility * 1000)
                             .OrderBy(i => i.Distance);

                //Select visible points
                List <GpsLocation> tmpVisiblePoints = new List <GpsLocation>();
                double             maxViewAngle     = -90;
                foreach (var point in points)
                {
                    if (point.VerticalViewAngle > maxViewAngle)
                    {
                        tmpVisiblePoints.Add(point);
                        maxViewAngle = point.VerticalViewAngle.Value;
                    }
                }

                //Change order (now from the furthest to the nearest)
                tmpVisiblePoints.Reverse();

                //... and ignore points on descending slope
                GpsLocation lastPoint      = null;
                GpsLocation lastAddedPoint = null;
                var         ed             = new ElevationData(group.Angle);
                foreach (var point in tmpVisiblePoints)
                {
                    if (lastPoint == null)
                    {
                        ed.Add(point);
                        lastAddedPoint = point;
                        lastPoint      = point;
                        continue;
                    }

                    //TODO: comment-out the folowing if for full rendering
                    var distanceDiff = lastPoint.Distance.Value - point.Distance.Value;
                    if (distanceDiff < lastPoint.Distance / 100 + 50)
                    {
                        lastPoint = point;
                        continue;
                    }

                    ed.Add(point);
                    lastAddedPoint = point;
                    lastPoint      = point;
                }
                _elevationProfileData.Add(ed);
            }
        }
コード例 #2
0
        private ElevationData GetElevationDataForAngle(ushort angle, GpsLocation myLocation, double maxDistance, ElevationTileCollection etc)
        {
            var ed = new ElevationData(angle);

            for (double d = 500; d < maxDistance; d += Math.Min(100, d / 100))
            {
                var x = GpsUtils.QuickGetGeoLocation(myLocation, d, angle);
                //int size = d < 5000 ? 1 : 3;
                int size = Math.Min(((int)d / 20000) + 1, 4);//0-20:1 20-40:2 40-60:3 60-100:4
                if (etc.TryGetElevation(x, out var elevation, size))
                {
                    x.Altitude = elevation;
                    x.Distance = d;
                    x.Bearing  = angle;
                    x.GetVerticalViewAngle(myLocation);

                    ed.Add(x);
                }
            }

            return(ed);
        }