/// <summary> /// Adjust parameters specific to this track when new data is entered. Adjusts values for time span and location /// </summary> /// <param name="data">New data being added</param> private void AdjustForInput(GpsPoint data) { if (data.Time != 0) { if (data.Time < this.startTime) { this.startTime = data.Time; } if (data.Time > this.endTime) { this.endTime = data.Time; } } if (data.Date != 0) { if (data.Date < this.startDate) { this.startDate = data.Date; } if (data.Date > this.endDate) { this.endDate = data.Date; } } if (data.Latitude.Value > maxLatitude) { maxLatitude = data.Latitude.Value; } else if (data.Latitude.Value < minLatitude) { minLatitude = data.Latitude.Value; } if (data.Longitude.Value > maxLongitude) { maxLongitude = data.Longitude.Value; } else if (data.Longitude.Value < minLongitude) { minLongitude = data.Longitude.Value; } }
public GpsTrack ReadGpsLog() { using (StreamReader sr = File.OpenText(fileName)) { GpsPoint point = null; GpsData data; string s = String.Empty; double currentTime = 0; // Note, can only use the time, not date, because date is not included in GPGGA values. Assume data point is the same if time is the same, independent of date while ((s = sr.ReadLine()) != null) { data = ParseLine(s); if (data == null) { continue; } // if the new data is at a different time than the previous then it is a new data point location if (typeof(GpsDataTimeLocation).IsAssignableFrom(data.GetType()) && ((GpsDataTimeLocation)data).Time != currentTime) { point = new GpsPoint((GpsDataTimeLocation)data); // old point is finished, add to the list and start a new one if (point != null) { if (track == null) { track = new GpsTrack((GpsDataTimeLocation)data); } track.AddPoint(point); } currentTime = ((GpsDataTimeLocation)data).Time; } point.AddData(data); } track.AddPoint(point); } return(track); }
public void AddPoint(GpsPoint point) { AdjustForInput(point); points.Add(point); }