]> granicus.if.org Git - postgis/commitdiff
ST_AsLatLonText: round minutes
authorSandro Santilli <strk@kbt.io>
Wed, 18 Jan 2017 20:58:59 +0000 (20:58 +0000)
committerSandro Santilli <strk@kbt.io>
Wed, 18 Jan 2017 20:58:59 +0000 (20:58 +0000)
Patch by Mike Toews, see #3688

git-svn-id: http://svn.osgeo.org/postgis/trunk@15288 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_print.c
liblwgeom/lwprint.c

index 782aa99e8bed383d16b0fe32a8ed92a3b8b6976c..319e39a291a23ef19aa6d3363a51b6bb84e36b89 100644 (file)
@@ -80,6 +80,8 @@ static void test_lwprint_default_format(void)
        test_lwprint_assert_format("POINT(-181 -91)",           ""  , "89\xC2\xB0""0'0.000\"S 1\xC2\xB0""0'0.000\"W");
        test_lwprint_assert_format("POINT(-180.0001 -90.0001)", NULL, "89\xC2\xB0""59'59.640\"S 0\xC2\xB0""0'0.360\"W");
        test_lwprint_assert_format("POINT(-2348982391.123456 -238749827.34879)", ""  , "12\xC2\xB0""39'4.356\"N 31\xC2\xB0""7'24.442\"W");
+       /* See https://trac.osgeo.org/postgis/ticket/3688 */
+       test_lwprint_assert_format("POINT (76.6 -76.6)",        NULL, "76\xC2\xB0""36'0.000\"S 76\xC2\xB0""36'0.000\"E");
 }
 
 /*
index 7265d7a94d657a80b33f22fe860842e570471345..df3add67be269154f5cc4b835b72a4904fadb099 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <math.h>
 #include "liblwgeom_internal.h"
 
 /* Ensures the given lat and lon are in the "normal" range:
@@ -313,7 +314,7 @@ static char * lwdouble_to_dms(double val, const char *pos_dir_symbol, const char
        if (min_digits > 0)
        {
                degrees = (long)degrees;
-               minutes = (val - degrees) * 60;
+               minutes = fmod(val * 10, 10) * 6;
        }
        if (sec_digits > 0)
        {