Ejemplo n.º 1
0
        private static Record ParseRecord(string aLine)
        {
            NumberFormatInfo info = NumberFormatInfo.InvariantInfo;

            string[] fields = aLine.Split(',');

            Record result = new Record();
            result.Time = GetDateTime(fields[0]);
            result.Location = new PointLatLng(double.Parse(fields[1], info), double.Parse(fields[2], info));
            result.Altitude = float.Parse(fields[3], info);
            result.VelocityNorth = float.Parse(fields[4], info);
            result.VelocityEast = float.Parse(fields[5], info);
            result.VelocityDown = float.Parse(fields[6], info);
            return result;
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        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++;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        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;
        }