summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2006-10-29 00:43:00 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2006-10-29 00:43:00 +0200
commit20d0a75d72711a11694c4796529acba280ac9443 (patch)
tree3805feb78d074887f16ed6373f12a673917b64a9
parent2c4c48b59dea2e96ff34469627bc2c5cf2c53f5a (diff)
use Exif GPS Info if available
-rw-r--r--src/ExifImageMetaData.cxx35
-rw-r--r--src/GipfelWidget.cxx3
2 files changed, 37 insertions, 1 deletions
diff --git a/src/ExifImageMetaData.cxx b/src/ExifImageMetaData.cxx
index 0de7478..4002e97 100644
--- a/src/ExifImageMetaData.cxx
+++ b/src/ExifImageMetaData.cxx
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <sys/wait.h>
#include "util.h"
@@ -26,6 +27,29 @@
#include "ExifImageMetaData.H"
#define FOCAL_LENGTH_IN_35MM_FILM 0xa405
+#define GPS_LATIITUDE 0x0002
+#define GPS_LONGITUDE 0x0004
+#define GPS_ALTITUDE 0x0006
+
+
+static double
+degminsecstr2double(char *val) {
+ double ret, dv;
+
+ ret = 0.0;
+ for (dv=1.0; dv <= 3600.0; dv = dv * 60.0) {
+ ret = ret + atof(val) / dv;
+ val = strchr(val, ',');
+ if (!val || val[1] == '\0') {
+ break;
+ } else {
+ val++;
+ }
+ }
+
+ return ret;
+}
+
int
ExifImageMetaData::load_image(char *name) {
@@ -47,7 +71,7 @@ ExifImageMetaData::load_image(char *name) {
if (p) {
while (fgets(buf, sizeof(buf), p) != NULL) {
- if (sscanf(buf, "%x\t%s", &id, val) != 2) {
+ if (sscanf(buf, "%x\t%[^\n]\n", &id, val) != 2) {
continue;
}
@@ -55,6 +79,15 @@ ExifImageMetaData::load_image(char *name) {
case FOCAL_LENGTH_IN_35MM_FILM:
focallength_sensor_ratio = atof(val) / 35.0;
break;
+ case GPS_LONGITUDE:
+ longitude = degminsecstr2double(val);
+ break;
+ case GPS_LATIITUDE:
+ latitude = degminsecstr2double(val);
+ break;
+ case GPS_ALTITUDE:
+ height = atof(val);
+ break;
}
}
}
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index 33a3987..b8ebc79 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -130,6 +130,9 @@ GipfelWidget::load_image(char *file) {
ret = md->load_image(file);
if (ret == 0) {
set_scale(md->get_focallength_sensor_ratio() * img->w());
+ set_view_long(md->get_longitude());
+ set_view_lat(md->get_latitude());
+ set_view_height(md->get_height());
}
delete md;
}