/// <summary> /// Prepares a single track edit from all of the data in a given file /// </summary> public TrackEditData PreviewTrack(string uri) { // load file and read data var file = new FileInfo(uri); var read = new GpxFileReader(file.FullName); var data = read.ReadFile(); // create new extract entity var track = new TrackEditData(); track.Key = Graffiti.Crypto.GetNewHash(); track.Source = file.FullName; // set default name value track.Name = data.Name; if (String.IsNullOrWhiteSpace(track.Name)) { track.Name = Path.GetFileNameWithoutExtension(file.Name); } // prepare points and source points lists track.DataPoints = data.Tracks.SelectMany(x => x.PointData).ToList(); track.Points = track.DataPoints.ToList <IGpxPoint>(); return(track); }
/// <summary> /// Creates track edits for each track in the file data /// </summary> public List <TrackEditData> CreateTracks(string uri) { // load file and read data var file = new FileInfo(uri); var read = new GpxFileReader(file.FullName); var data = read.ReadFile(); var tracks = new List <TrackEditData>(); foreach (var t in data.Tracks) { // create new extract entity var track = new TrackEditData(); track.Key = Graffiti.Crypto.GetNewHash(); track.Source = t.Source; track.Name = t.Name; track.Description = t.Description; track.DataPoints = t.PointData; track.Points = t.Points; // default missing properties if (String.IsNullOrWhiteSpace(track.Source)) { track.Source = file.FullName; } if (String.IsNullOrWhiteSpace(track.Name)) { track.Source = Path.GetFileNameWithoutExtension(file.Name); } // add to edit session _tracks.Add(track); tracks.Add(track); } return(tracks); }