public void CanParseAll() { var gpx10 = new Gpx10Serializer(); var gpx11 = new Gpx11Serializer(); var dir = GetReferenceFileDirectory("gpx").EnumerateFiles(); foreach (var fileInfo in dir) { using (var stream = new FileStream(fileInfo.FullName, FileMode.Open)) { var streamWrapper = new StreamWrapper(stream); if (gpx10.CanDeSerialize(streamWrapper)) { var data = gpx10.DeSerialize(streamWrapper); data.ToGpx(); data.ToGpx(1); } else if (gpx11.CanDeSerialize(streamWrapper)) { var data = gpx11.DeSerialize(streamWrapper); data.ToGpx(); data.ToGpx(1); } else { Assert.True(false, fileInfo.Name); } } } }
public void CanParseAll() { var gpx10 = new Gpx10Serializer(); var gpx11 = new Gpx11Serializer(); var dir = GetReferenceFileDirectory("gpx").EnumerateFiles(); foreach (var fileInfo in dir) { using (var stream = new FileStream(fileInfo.FullName, FileMode.Open)) { var streamWrapper = new StreamWrapper(stream); if (gpx10.CanDeSerialize(streamWrapper)) { var data = gpx10.DeSerialize(streamWrapper); data.ToGpx(); data.ToGpx(1); } else if (gpx11.CanDeSerialize(streamWrapper)) { var data = gpx11.DeSerialize(streamWrapper); data.ToGpx(); data.ToGpx(1); } else { Assert.True(false, fileInfo.Name); } } } }
void Compare(Gpx11Serializer serializer, GpsData data, string gpxData) { using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(gpxData))) { GpsData data2 = serializer.DeSerialize(new StreamWrapper(stream)); Compare(data, data2); } }
private void LoadFiles(object sender, DoWorkEventArgs e) { int count = 0; this.TotalDistance = 0; foreach (string path in this.filenames) { if (chkFilenameMustContain.Checked && !(new FileInfo(path).Name.Contains(txtMustContain.Text))) { continue; } List <Geo.Gps.Track> tracks = null; var gpx10 = new Gpx10Serializer(); var gpx11 = new Gpx11Serializer(); using (var stream = new FileStream(path, FileMode.Open)) { var streamWrapper = new StreamWrapper(stream); if (gpx10.CanDeSerialize(streamWrapper)) { var data = gpx10.DeSerialize(streamWrapper); tracks = data.Tracks; } else if (gpx11.CanDeSerialize(streamWrapper)) { var data = gpx11.DeSerialize(streamWrapper); tracks = data.Tracks; } } foreach (var track in tracks) { if (chkAvgSpeedBetween.Checked) { Geo.Measure.Speed speed = track.GetAverageSpeed().ConvertTo(Geo.Measure.SpeedUnit.Kph); if (speed.Value < Convert.ToDouble(numSpeedFrom.Value) || speed.Value > Convert.ToDouble(numSpeedTo.Value)) { continue; } } bool isAnyPointOnMap = false; if (chkLoadForVisibleMap.Checked) { foreach (var segment in track.Segments) { for (int idx = segment.Fixes.Count - 1; idx >= 0; idx--) { if (segment.Fixes[idx].Coordinate.Latitude >= ViewArea.Bottom && segment.Fixes[idx].Coordinate.Latitude <= ViewArea.Top && segment.Fixes[idx].Coordinate.Longitude >= ViewArea.Left && segment.Fixes[idx].Coordinate.Longitude <= ViewArea.Right) { isAnyPointOnMap = true; break; } } } } else { isAnyPointOnMap = true; } bool betweenAnyDates = false; if (chkDatesBetween.Checked) { foreach (var segment in track.Segments) { for (int idx = segment.Fixes.Count - 1; idx >= 0; idx--) { if (segment.Fixes[idx].TimeUtc.Date >= dtFrom.Value && segment.Fixes[idx].TimeUtc.Date <= dtTo.Value) { betweenAnyDates = true; break; } } } } else { betweenAnyDates = true; } if (isAnyPointOnMap && betweenAnyDates) { Geo.Gps.Fix firstPoint = track.GetFirstFix(); if (firstPoint.TimeUtc < minTrackDate) { minTrackDate = firstPoint.TimeUtc; } if (firstPoint.TimeUtc > maxTrackDate) { maxTrackDate = firstPoint.TimeUtc; } this.TotalDistance += track.GetLength().Value; this.TotalTime += track.GetDuration(); Geo.Measure.Speed speed = track.GetAverageSpeed(); this.avgSpeedSum += speed.SiValue; this.avgSpeedCount++; track.Metadata.Add("filename", new FileInfo(path).Name); this.Tracks.Add(track); } } count++; ((BackgroundWorker)sender).ReportProgress((int)((double)count / (double)this.filenames.Length * 100f)); } ((BackgroundWorker)sender).ReportProgress(100); }