[postgis-tickets] r15289 - ST_AsLatLonText: round minutes [2.3 backport]

Sandro Santilli strk at kbt.io
Wed Jan 18 13:07:16 PST 2017


Author: strk
Date: 2017-01-18 13:07:16 -0800 (Wed, 18 Jan 2017)
New Revision: 15289

Modified:
   branches/2.3/NEWS
   branches/2.3/liblwgeom/cunit/cu_print.c
   branches/2.3/liblwgeom/lwprint.c
Log:
ST_AsLatLonText: round minutes [2.3 backport]

Patch by Mike Toews, closes #3688

Modified: branches/2.3/NEWS
===================================================================
--- branches/2.3/NEWS	2017-01-18 20:58:59 UTC (rev 15288)
+++ branches/2.3/NEWS	2017-01-18 21:07:16 UTC (rev 15289)
@@ -2,10 +2,11 @@
 2017/MM/DD
 
   * Bug Fixes
-  
+
   - #3418, KNN recheck in 9.5+ fails with index returned tuples in wrong order
   - #3675, Relationship functions not using an index in some cases
   - #3680, PostGIS upgrade scripts missing GRANT for views
+  - #3688, ST_AsLatLonText: round minutes
 
 PostGIS 2.3.1
 2016/11/28

Modified: branches/2.3/liblwgeom/cunit/cu_print.c
===================================================================
--- branches/2.3/liblwgeom/cunit/cu_print.c	2017-01-18 20:58:59 UTC (rev 15288)
+++ branches/2.3/liblwgeom/cunit/cu_print.c	2017-01-18 21:07:16 UTC (rev 15289)
@@ -80,6 +80,8 @@
 	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");
 }
 
 /*

Modified: branches/2.3/liblwgeom/lwprint.c
===================================================================
--- branches/2.3/liblwgeom/lwprint.c	2017-01-18 20:58:59 UTC (rev 15288)
+++ branches/2.3/liblwgeom/lwprint.c	2017-01-18 21:07:16 UTC (rev 15289)
@@ -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 @@
 	if (min_digits > 0)
 	{
 		degrees = (long)degrees;
-		minutes = (val - degrees) * 60;
+		minutes = fmod(val * 10, 10) * 6;
 	}
 	if (sec_digits > 0)
 	{



More information about the postgis-tickets mailing list