go through gps data backwards

This commit is contained in:
Colin McMillen 2023-08-30 13:59:35 -04:00
parent c0ac67103f
commit 3d4ad61f5e

View File

@ -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;