mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Info dialog: print coordinates using an ASCII 'dtoa' type of method
dac29e7bc4
introduced changes to how the GPS coordinate string
is parsed; we now prefer to parse decimal numbers using the '.'
character.
This patch makes modifications to info.c:print_gps_coordinates(),
where we are still using a locale dependent method for converting
a double to string - snprintf(). Instead, we attempt to use GLib's
g_ascii_formatd(), and store the resulted strings into two
buffers named 'dbuf_lat' and 'dbuf_lon'. We then pass the buffers
to the final snprintf() formatting with '%s'.
Reported-and-tested-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6dd31a6cc6
commit
6c7e2f9ffa
1 changed files with 11 additions and 4 deletions
15
info.c
15
info.c
|
@ -644,7 +644,7 @@ static void print_gps_coordinates(char *buffer, int len, int lat, int lon)
|
||||||
{
|
{
|
||||||
unsigned int latdeg, londeg;
|
unsigned int latdeg, londeg;
|
||||||
double latmin, lonmin;
|
double latmin, lonmin;
|
||||||
char *lath, *lonh;
|
char *lath, *lonh, dbuf_lat[32], dbuf_lon[32];
|
||||||
|
|
||||||
if (!lat && !lon) {
|
if (!lat && !lon) {
|
||||||
*buffer = 0;
|
*buffer = 0;
|
||||||
|
@ -658,9 +658,16 @@ static void print_gps_coordinates(char *buffer, int len, int lat, int lon)
|
||||||
londeg = lon / 1000000;
|
londeg = lon / 1000000;
|
||||||
latmin = (lat % 1000000) * 60.0 / 1000000.0;
|
latmin = (lat % 1000000) * 60.0 / 1000000.0;
|
||||||
lonmin = (lon % 1000000) * 60.0 / 1000000.0;
|
lonmin = (lon % 1000000) * 60.0 / 1000000.0;
|
||||||
snprintf(buffer, len, "%s%u%s %8.5f\' , %s%u%s %8.5f\'",
|
*dbuf_lat = *dbuf_lon = 0;
|
||||||
lath, latdeg, UTF8_DEGREE, latmin,
|
g_ascii_formatd(dbuf_lat, sizeof(dbuf_lat), "%8.5f", latmin);
|
||||||
lonh, londeg, UTF8_DEGREE, lonmin);
|
g_ascii_formatd(dbuf_lon, sizeof(dbuf_lon), "%8.5f", lonmin);
|
||||||
|
if (!*dbuf_lat || !*dbuf_lon) {
|
||||||
|
*buffer = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
snprintf(buffer, len, "%s%u%s %s\' , %s%u%s %s\'",
|
||||||
|
lath, latdeg, UTF8_DEGREE, dbuf_lat,
|
||||||
|
lonh, londeg, UTF8_DEGREE, dbuf_lon);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_gps_entry(int lat, int lon)
|
static void update_gps_entry(int lat, int lon)
|
||||||
|
|
Loading…
Add table
Reference in a new issue