public static void DeleteEntry(LogEntry aEntry) { if (aEntry != null) { if (mEntries.Remove(aEntry.Key)) { Dirty = true; FireEntriesChanged(); } } }
public static LogEntry Import(string aKey, string aPath) { string[] lines = File.ReadAllLines(aPath); if (lines.Length > 2) { Record rec = ParseRecord(lines[2]); LogEntry entry = new LogEntry(aKey, rec.Time, lines.Length); entry.Records.Add(rec); for (int i = 3; i < lines.Length; i++) { entry.Records.Add(ParseRecord(lines[i])); } return entry; } return null; }
public static void CalculateMissingData(LogEntry aEntry) { int num = aEntry.Records.Count; for (int i = 1; i < num; i++) { Record a = aEntry.Records[i]; Record b = aEntry.Records[i - 1]; // calculate differences. double timeDiff = (a.Time - b.Time).TotalSeconds; double altitudeDiff = a.Altitude - b.Altitude; double latDiff = DistanceInMeters(a.Location.Lat, b.Location.Lat); double lngDiff = DistanceInMeters(a.Location.Lng, b.Location.Lng); // calculate velocities. a.VelocityDown = (float)(-altitudeDiff / timeDiff); a.VelocityNorth = (float)(latDiff / timeDiff); a.VelocityEast = (float)(-lngDiff / timeDiff); // store result. aEntry.Records[i] = a; } }
private static void AddEntry(string aName, LogEntry aEntry) { if (aEntry != null) { Dirty = true; mEntries.Add(aName, aEntry); } }
public static void Import(string aKey, GpxFile aFile, AddEntryCallback aCallback) { if (aFile != null) { // apply some basic filtering of loaded GPX data FileFilterChain filterChain = new FileFilterChain(); filterChain.Filters.Add(new RemoveErrorPointsFilter()); aFile = filterChain.ApplyFilters(aFile); // convert to LogEntry. int idx = 0; foreach (Track track in aFile.Tracks) { if (track.Segments.Count > 0) { TrackSegment firstSeg = track.Segments[0]; string key = string.Format("{0}/{1}[{2}]", aKey, track.Name, idx); DateTime time = (DateTime)firstSeg.StartTime; LogEntry entry = new LogEntry(key, time, firstSeg.PointsCount); foreach (TrackSegment seg in track.Segments) { foreach (TrackPoint pnt in seg.Points) { Record rec = new Record(); rec.Location = new PointLatLng(pnt.Location.Y, pnt.Location.X); if (pnt.Time != null) { rec.Time = (DateTime)pnt.Time; } if (pnt.Elevation != null) { rec.Altitude = (float)pnt.Elevation; } entry.Records.Add(rec); } } CalculateMissingData(entry); aCallback(key, entry); idx++; } } } }
public static LogEntry Read(string aKey, BinaryReader aReader) { int version = aReader.ReadByte(); DateTime date = DateTime.FromBinary(aReader.ReadInt64()); int count = aReader.ReadInt32(); LogEntry result = new LogEntry(aKey, date, count); for (int i = 0; i < count; ++i) { Record rec = new Record(); rec.Time = DateTime.FromBinary(aReader.ReadInt64()); rec.Location = new PointLatLng(aReader.ReadDouble(), aReader.ReadDouble()); rec.Altitude = aReader.ReadSingle(); rec.VelocityNorth = aReader.ReadSingle(); rec.VelocityEast = aReader.ReadSingle(); rec.VelocityDown = aReader.ReadSingle(); result.Records.Add(rec); } return result; }