From: Sandro Santilli Date: Wed, 18 Jan 2017 20:58:59 +0000 (+0000) Subject: ST_AsLatLonText: round minutes X-Git-Tag: 2.4.0alpha~183 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4dfe9b9e97cdd466288db26a2b23f92ea6b99756;p=postgis ST_AsLatLonText: round minutes Patch by Mike Toews, see #3688 git-svn-id: http://svn.osgeo.org/postgis/trunk@15288 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/cunit/cu_print.c b/liblwgeom/cunit/cu_print.c index 782aa99e8..319e39a29 100644 --- a/liblwgeom/cunit/cu_print.c +++ b/liblwgeom/cunit/cu_print.c @@ -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"); } /* diff --git a/liblwgeom/lwprint.c b/liblwgeom/lwprint.c index 7265d7a94..df3add67b 100644 --- a/liblwgeom/lwprint.c +++ b/liblwgeom/lwprint.c @@ -26,6 +26,7 @@ #include #include +#include #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) {