summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-04-07 17:45:18 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-04-07 17:45:18 +0200
commit37a37e91ca0276e5dbb2864ede644d71e5687a7e (patch)
treec79e3e182a08c46b2d9e76fcd881dcb4969cc05f
parentbfdce4d192a946521d54079cf15b9da79ab1316e (diff)
factor out gpsSetCoordinate()
-rw-r--r--configure.ac2
-rw-r--r--src/ImageMetaData.cxx43
2 files changed, 20 insertions, 25 deletions
diff --git a/configure.ac b/configure.ac
index 09b9b44..9d9a4e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,7 +62,7 @@ AC_CHECK_LIB([tiff], [TIFFOpen], [], [echo "Error: libtiff.so not found."; exit
# Check for exiv2
AC_CHECK_HEADERS([exiv2/exif.hpp], [], [echo "Error: exiv2/exif.hpp not found."; exit 1;])
-LIBS="$LIBS -lexiv2"
+LIBS="-lexiv2 $LIBS"
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx
index 19d9e27..902425a 100644
--- a/src/ImageMetaData.cxx
+++ b/src/ImageMetaData.cxx
@@ -72,6 +72,21 @@ ImageMetaData::save_image(char *in_img, char *out_img) {
return save_image_jpgcom(in_img, out_img);
}
+static void
+gpsSetCoordinate(double *destVal, Exiv2::ExifData *exifData, const char *name) {
+ Exiv2::ExifKey key(name);
+ Exiv2::ExifData::iterator pos = exifData->findKey(key);
+
+ if (pos != exifData->end()) {
+ if (pos->toFloat() >= 0)
+ *destVal = pos->toFloat();
+ if (pos->toFloat(1) >= 0)
+ *destVal += pos->toFloat(1) / 60;
+ if (pos->toFloat(2) >= 0)
+ *destVal += pos->toFloat(2) / 3600;
+ }
+}
+
int
ImageMetaData::load_image_exif(char *name) {
Exiv2::Image::AutoPtr image;
@@ -120,31 +135,11 @@ ImageMetaData::load_image_exif(char *name) {
_focal_length_35mm = pos->toFloat();
}
- if (isnan(_longitude)) {
- Exiv2::ExifKey key("Exif.GPSInfo.GPSLongitude");
- pos = exifData.findKey(key);
- if (pos != exifData.end()) {
- if ( pos->toFloat() >= 0)
- _longitude = pos->toFloat();
- if ( pos->toFloat(1) >= 0)
- _longitude += pos->toFloat(1) / 60;
- if ( pos->toFloat(2) >= 0)
- _longitude += pos->toFloat(2) / 3600;
- }
- }
+ if (isnan(_longitude))
+ gpsSetCoordinate(&_longitude, &exifData, "Exif.GPSInfo.GPSLongitude");
- if (isnan(_latitude)) {
- Exiv2::ExifKey key("Exif.GPSInfo.GPSLatitude");
- pos = exifData.findKey(key);
- if (pos != exifData.end()) {
- if ( pos->toFloat() >= 0)
- _latitude = pos->toFloat();
- if ( pos->toFloat(1) >= 0)
- _latitude += pos->toFloat(1) / 60;
- if ( pos->toFloat(2) >= 0)
- _latitude += pos->toFloat(2) / 3600;
- }
- }
+ if (isnan(_latitude))
+ gpsSetCoordinate(&_longitude, &exifData, "Exif.GPSInfo.GPSLatitude");
if (isnan(_height)) {
Exiv2::ExifKey key("Exif.GPSInfo.GPSAltitude");