diff --git a/Program.cs b/Program.cs index be8ca54..0536da1 100644 --- a/Program.cs +++ b/Program.cs @@ -704,16 +704,18 @@ public class Game : GameWindow { allPhotos.Sort(ComparePhotosByDate); - // Fix up photos with missing GPS. + // Fix up photos with missing GPS. We start at the end and work our way + // backwards, because if one photo is missing GPS, it's probably because + // the camera was turned off for a while, and whichever photo *after* it + // has GPS data is probably more accurate. GpsInfo? lastGps = null; - foreach (Photo p in allPhotos) { - if (p.Gps != null) { - lastGps = p.Gps; - } + for (int i = allPhotos.Count - 1; i >= 0; i--) { + Photo p = allPhotos[i]; if (p.Gps == null) { - // FIXME: should we take from the photo immediately _before_, or after? Console.WriteLine("fixing GPS for " + p.Filename); p.Gps = lastGps; + } else { + lastGps = p.Gps; } } photos = allPhotos;