public void PopulateDataTable(GPXAnalyzer frm, int Trackidx) { if (Trackidx >= 0) { trkType track = gpxInfo.trk[Trackidx]; trksegType seg = track.trkseg[0]; wptType wpt, wptPrev = null; double legLength; decimal ele; double speed = 0D; string name; decimal total_ascent = 0; decimal total_descent = 0; double total_distance = 0D; decimal ele_diff = 0; TimeSpan elapsedTime = new TimeSpan(0L); TimeSpan legTime = new TimeSpan(0L); for (int iPoint = 0; iPoint < seg.trkpt.Length; iPoint++) { wpt = seg.trkpt[iPoint]; if (wpt.name == null || wpt.name.Equals("")) name = "WP:" + iPoint; else name = wpt.name; legLength = distances[iPoint]; total_distance += legLength; ele = wpt.ele; if (wptPrev != null) { legTime = wpt.time - wptPrev.time; elapsedTime += legTime; speed = legLength / legTime.Seconds; // in metres/sec speed = (legTime.Seconds * 1609.344) / (legLength * 60.0); //in minute miles // if ((total_distance / 1609.344)) ele_diff = wpt.ele - wptPrev.ele; if (ele_diff < 0) total_descent += -ele_diff; else total_ascent += ele_diff; } frm.dgvData_addRow(name, legLength, ele, wpt.time, speed, total_ascent, total_descent, total_distance, elapsedTime); frm.DGVDataEntry_addRow(name, wpt.lat, wpt.lon); wptPrev = wpt; } // frm.dgvData_addRow } }
public PointF[] GenerateTrackGraphic(GPXAnalyzer frm, int Trackidx, int width, int height, int borderWidth) { PointF[] Points = new PointF[0]; if (!ValidTrack(Trackidx)) return Points; if (gpxInfo != null) { // Compute scale factor double dlat = (double)(trackBounds.maxlat - trackBounds.minlat); double dlon = (double)(trackBounds.maxlon - trackBounds.minlon); double xScale = (width - 2 * borderWidth) / dlon; double yScale = (height - 2 * borderWidth) / dlat; xScale = Math.Min(xScale, yScale); yScale = xScale; trkType track = gpxInfo.trk[Trackidx]; trksegType seg = track.trkseg[0]; Points = new PointF[seg.trkpt.Length]; wptType wpt; for (int iPoint = 0; iPoint < seg.trkpt.Length; iPoint++) { wpt = seg.trkpt[iPoint]; PointF pt = frm.LatLonToScreen((double)wpt.lat, (double)wpt.lon, (double)trackBounds.minlat, (double)trackBounds.minlon, xScale, yScale); Points[iPoint] = pt; } } return Points; }
public void DisplayTrack(GPXAnalyzer frm) { int nTracks = 0; frm.clearTracks(); frm.clearPoints(); if (gpxInfo.trk != null) { // populate tracks listbox nTracks = gpxInfo.trk.Length; foreach (trkType track in gpxInfo.trk) { frm.AddTrackName(track.name); } } /* if (nTracks > 0) { // Select the first track // This raises the SelectedIndexChanged event. frm.lblTracks.SelectedIndex = 0; } */ frm.SetTrackText(string.Format("{0} Tracks in {1}", nTracks, Text)); }
public PointF[] GenerateElevationGraphic(GPXAnalyzer frm, int Trackidx, int width, int height, int borderWidth) { trkType track = gpxInfo.trk[Trackidx]; trksegType seg = track.trkseg[0]; wptType wpt; wptType wptPrev = seg.trkpt[0]; double runningDist = 0; PointF[] Points = new PointF[seg.trkpt.Length]; SetupTrackData(Trackidx); // Compute scale factor // Determine elevation difference. double dele = maxEle - minEle; double xScale = (width - 2 * borderWidth) / totalDist; double yScale = (height - 2 * borderWidth) / dele; // Calculate graphics code for (int iPoint = 0; iPoint < seg.trkpt.Length; iPoint++) { wpt = seg.trkpt[iPoint]; runningDist += distances[iPoint]; //stored geo calc PointF pt = frm.DistEleToScreen(runningDist, (double)wpt.ele, minEle, xScale, yScale); Points[iPoint] = pt; wptPrev = wpt; } // Draw the lines between the points return Points; }
// Fills the Points list box with the track points // from the selected track and computes totals for the track. public void DisplayPoints(GPXAnalyzer frm, int whichTrack) { if (whichTrack < 0) return; trkType track = gpxInfo.trk[whichTrack]; if (track == null) return; trksegType seg = track.trkseg[0]; wptType wpt; wptType wptPrev = null; SetupTrackData( whichTrack ); frm.SetPointsText(string.Format("{0} Points", seg.trkpt.Length)); for (int iPoint = 0; iPoint < seg.trkpt.Length; iPoint++) { wpt = seg.trkpt[iPoint]; string spt; if (wpt.name != null && !(wpt.name == string.Empty)) { spt = string.Format("{0,-5} {1}", iPoint + 1, wpt.name); } else { spt = string.Format("{0,-5} {1}", iPoint + 1, GPXUtils.LatLonToString((double)wpt.lat, (double)wpt.lon)); } frm.AddPointsName(spt); wptPrev = wpt; } }