summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Riemann <[email protected]>2014-02-28 22:52:56 +0100
committerraveit65 <[email protected]>2018-07-26 00:45:21 +0200
commit9b4890eac998316d72e2358aa0bf5a8f3166afb3 (patch)
tree97df5ad61fcdb2d266cd438728eb9db36b0ab599
parentf965eb23880167ea4889c6043b1d46b312aebe76 (diff)
downloadeom-9b4890eac998316d72e2358aa0bf5a8f3166afb3.tar.bz2
eom-9b4890eac998316d72e2358aa0bf5a8f3166afb3.tar.xz
EomMetadataDetails: Improve fractional GPS coordinates support
Increase displayed coordinate resolution for Exif GPS coordinates that use fractional degrees for minutes or fractional minutes for seconds. https://bugzilla.gnome.org/show_bug.cgi?id=725416 origin commit: https://gitlab.gnome.org/GNOME/eog/commit/1b0fb6b
-rw-r--r--src/eom-metadata-details.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/eom-metadata-details.c b/src/eom-metadata-details.c
index ebb63bb..9947300 100644
--- a/src/eom-metadata-details.c
+++ b/src/eom-metadata-details.c
@@ -39,6 +39,7 @@
#include <gtk/gtk.h>
#include <string.h>
+#include <math.h>
typedef enum {
EXIF_CATEGORY_CAMERA,
@@ -372,7 +373,7 @@ eom_exif_entry_get_value (ExifEntry *e,
{
gsize rational_size;
ExifRational r;
- gfloat h = 0., m = 0.;
+ gfloat h = 0., m = 0., s = 0.;
rational_size = exif_format_get_size (EXIF_FORMAT_RATIONAL);
@@ -385,15 +386,33 @@ eom_exif_entry_get_value (ExifEntry *e,
h = (gfloat)r.numerator / r.denominator;
r = exif_get_rational (e->data + rational_size, bo);
- if (r.denominator != 0)
- m = (gfloat)r.numerator / (gfloat)r.denominator;
+ if (r.denominator != 0) {
+ if (r.numerator != 0) {
+ m = (gfloat)r.numerator /
+ (gfloat)r.denominator;
+ } else {
+ double integ;
+
+ m = (gfloat)(modf (h, &integ) * 60.0);
+ h = (gfloat) integ;
+ }
+ }
r = exif_get_rational (e->data + (2 * rational_size),
bo);
- if (r.numerator != 0 && r.denominator != 0) {
- gfloat s;
-
- s = (gfloat)r.numerator / (gfloat)r.denominator;
+ if (r.denominator != 0) {
+ if (r.numerator != 0) {
+ s = (gfloat)r.numerator /
+ (gfloat)r.denominator;
+ } else {
+ double integ;
+
+ s = (gfloat)(modf (m, &integ) * 60.0);
+ m = (gfloat) integ;
+ }
+ }
+
+ if (s != 0.0) {
g_snprintf (buf, n_buf,
"%.0f° %.0f' %.2f\"",
h, m, s);