private static void WritePointsAsGpx(string outputPath, List <Position> sortedPoints) { var points = sortedPoints.Select(p => new Wpt((decimal)p.Latitude, (decimal)p.Longitude) { Time = p.Time.UtcDateTime, TimeSpecified = true }).ToList(); if (!points.Any()) { using (var se = new StreamWriter(System.Console.OpenStandardError())) { se.WriteLine("Couldn't find any pictures with GPS coordinates"); return; } } var gpx = new GPXLib(); int trackIndex = 0; DateTime lastPointTime = points[trackIndex].Time; foreach (var point in points) { if (point.Time.Subtract(lastPointTime).TotalHours > 5) { trackIndex++; } lastPointTime = point.Time; gpx.AddTrackPoint($"maintrack{trackIndex}", 0, point); } gpx.SaveToFile(Path.Combine(outputPath, "track.gpx")); File.WriteAllText(Path.Combine(outputPath, "track.json"), JsonConvert.SerializeObject(sortedPoints)); }