From: Colin Clark Date: Wed, 24 Jul 2019 15:47:06 +0000 (+0100) Subject: Fix #691: wrong GPS X-Git-Tag: v1.5~3 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=69b6794d32a19c8985e73fe85188f6c128b8f2f5 Fix #691: wrong GPS https://github.com/BestImageViewer/geeqie/issues/691 European locales use a comma as a decimal separator. The XMP spec. specifies a dot as a decimal separator. --- diff --git a/src/metadata.c b/src/metadata.c index e2e36113..98232ff0 100644 --- a/src/metadata.c +++ b/src/metadata.c @@ -19,6 +19,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + #include "main.h" #include "metadata.h" @@ -859,6 +861,7 @@ gboolean metadata_write_GPS_coord(FileData *fd, const gchar *key, gdouble value) char *coordinate; char *ref; gboolean ok = TRUE; + char *old_locale, *saved_locale; param = value; if (param < 0) @@ -883,8 +886,20 @@ gboolean metadata_write_GPS_coord(FileData *fd, const gchar *key, gdouble value) if (ok) { + /* Avoid locale problems with commas and decimal points in numbers */ + old_locale = setlocale(LC_ALL, NULL); + saved_locale = strdup(old_locale); + if (saved_locale == NULL) + { + return FALSE; + } + setlocale(LC_ALL, "C"); + coordinate = g_strdup_printf("%i,%lf,%s", deg, min, ref); metadata_write_string(fd, key, coordinate ); + + setlocale(LC_ALL, saved_locale); + free(saved_locale); g_free(coordinate); }