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); } }
public void Generate(GpsLocation _myLocation, double maxDistanceKm, ElevationTileCollection etc, Action <int> onProgressChange) { _elevationProfileData = new ElevationProfileData(_myLocation, maxDistanceKm); /*for (ushort angle = 0; angle < 360; angle++) * { * onProgressChange(angle); * * var ed = new ElevationData(angle); * * for (int d = 500; d < 12000; d += 25) * { * var x = GpsUtils.QuickGetGeoLocation(_myLocation, d, angle); * if (etc.TryGetElevation(x, out var elevation, 1)) * { * x.Altitude = elevation; * x.Distance = d; * x.Bearing = angle; * x.GetVerticalViewAngle(_myLocation); * * ed.Add(x); * } * } * * _elevationProfileData.Add(ed); * }*/ for (ushort a = 0; a < 360; a++) { onProgressChange(a); var ed = GetElevationDataForAngle(a, _myLocation, maxDistanceKm * 1000, etc); _elevationProfileData.Add(ed); } }