private static void GetSegmentDeltas(Point s, Point e, out double ascent, out double descent, out double hMax, out double hMin, SrtmRepository heightCache) { ascent = descent = 0; CalcSegmentIteratorsRetSeLen(s, e, out var stepLat, out var stepLon, out var nSteps); double latI = s.Lat; double lonI = s.Lon; var hprev = heightCache.GetHeightForPoint(new Point(latI, lonI)) ?? 0; hMin = hMax = hprev; for (var c = 1; c < nSteps; ++c) { latI += stepLat; lonI += stepLon; var h = heightCache.GetHeightForPoint(new Point(latI, lonI)) ?? 0; if (h > hprev) { ascent += h - hprev; } if (h < hprev) { descent += -(h - hprev); } if (h < hMin) { hMin = h; } if (h > hMax) { hMax = h; } hprev = h; } }
public static void GetHeightDetailsAccurate(List <Point> lst, out double ascentTotal, out double descentTotal, out double hstart, out double hend, out double hmax, out double hmin, out int ihmax, out int ihmin, SrtmRepository heightCache) { ascentTotal = 0; descentTotal = 0; hmax = hmin = hstart = heightCache.GetHeightForPoint(lst.First()) ?? 0; hend = heightCache.GetHeightForPoint(lst.Last()) ?? 0; ihmax = ihmin = 0; for (var c = 0; c < lst.Count - 1; ++c) { GetSegmentDeltas(lst[c], lst[c + 1], out var tacc, out var tdesc, out var thmax, out var thmin, heightCache); if (hmax < thmax) { hmax = thmax; ihmax = c; } if (hmin > thmin) { hmin = thmin; ihmin = c; } ascentTotal += tacc; descentTotal += tdesc; } }
public TrackReportVm(TrackVm source, IUiLoggingService loggingService, IUiService uiService, SrtmRepository srtmRepository, ITrackReportExporter[] reportExporters, Func <TrackVm, TrackReportItemVm> reportItemGenerator, TrekplannerConfiguration configuration) { _loggingService = loggingService; _uiService = uiService; _srtmRepository = srtmRepository; _reportExporters = reportExporters; _reportItemGenerator = reportItemGenerator; _configuration = configuration; Source = source; Totals = new TrackReportTotalsVm(this); Chart = new TrackChartVm(this); ExportCommand = new DelegateCommand(o => Results.Any(), ExportReportAsync); }