]> git.street.me.uk Git - andy/viking.git/commitdiff
[Geotagging] Improve detection of image files having GPS information.
authorRob Norris <rw_norris@hotmail.com>
Thu, 6 Sep 2012 20:14:26 +0000 (21:14 +0100)
committerRob Norris <rw_norris@hotmail.com>
Thu, 20 Sep 2012 00:45:15 +0000 (01:45 +0100)
Encountered some images which have just the EXIF_TAG_GPS_VERSION_ID but nothing else.
So to confirm GPS info, check existance of more EXIF GPS tags (Latitude and Longitude)

Thus when such images are requested for geotagging they won't be erroneously skipped over.

src/geotag_exif.c

index de446a155e0f5f33cca25f11fdfcba26fe092844..2dcb0fae1530e0d77484b996b5e19938ecbc3812 100644 (file)
@@ -307,6 +307,7 @@ VikWaypoint* a_geotag_waypoint_positioned ( const gchar *filename, VikCoord coor
 gchar* a_geotag_get_exif_date_from_file ( const gchar *filename, gboolean *has_GPS_info )
 {
        gchar* datetime = NULL;
+       *has_GPS_info = FALSE;
 
        ExifData *ed = exif_data_new_from_file ( filename );
 
@@ -324,13 +325,22 @@ gchar* a_geotag_get_exif_date_from_file ( const gchar *filename, gboolean *has_G
        }
 
        // Check GPS Info
-       *has_GPS_info = FALSE;
-       
+
        ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_VERSION_ID);
        // Confirm this has a GPS Id - normally "2.0.0.0" or "2.2.0.0"
        if ( ee && ee->components == 4 )
                *has_GPS_info = TRUE;
 
+       // Check other basic GPS fields exist too
+       // I have encountered some images which have just the EXIF_TAG_GPS_VERSION_ID but nothing else
+       // So to confirm check more EXIF GPS TAGS:
+       ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_LATITUDE);
+       if ( !ee )
+               *has_GPS_info = FALSE;
+       ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_LONGITUDE);
+       if ( !ee )
+               *has_GPS_info = FALSE;
+
        exif_data_free ( ed );
 
        return datetime;