[SCM] PostGIS branch stable-3.1 updated. 3.1.11-8-gad025e0ec

git at osgeo.org git at osgeo.org
Tue Aug 6 14:59:08 PDT 2024


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, stable-3.1 has been updated
       via  ad025e0ec4e54b04cf9aef4339f37409ba857b10 (commit)
       via  87891b5272eadbaca724deeba5f8adbf34f80ab0 (commit)
      from  0061ffe223de3bfb2b1e3e78ab681a60230ae539 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ad025e0ec4e54b04cf9aef4339f37409ba857b10
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Aug 6 14:59:04 2024 -0700

    Entry for #5745

diff --git a/NEWS b/NEWS
index c948a5e10..f99a001f8 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ xxxx/xx/xx
  - #5589, ST_3DDistance error for shared first point (Paul Ramsey)
  - #5686, ST_NumInteriorRings and Triangle crash (Paul Ramsey)
  - #5765, Handle nearly co-linear edges with slightly less slop (Paul Ramsey)
+ - #5745, St_AsLatLonText rounding errors (Paul Ramsey)
 
 
 PostGIS 3.1.11

commit 87891b5272eadbaca724deeba5f8adbf34f80ab0
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Aug 6 14:41:36 2024 -0700

    Fix St_AsLatLonText Rounding Errors, references #5745

diff --git a/liblwgeom/cunit/cu_print.c b/liblwgeom/cunit/cu_print.c
index 7274b6109..2f6c52284 100644
--- a/liblwgeom/cunit/cu_print.c
+++ b/liblwgeom/cunit/cu_print.c
@@ -204,6 +204,11 @@ test_lwpoint_to_latlon_format_orders(void)
 static void
 test_lwpoint_to_latlon_optional_format(void)
 {
+	test_lwpoint_to_latlon_assert_format("POINT(21.9999999 1)",
+		"D-M-S-C", "1-0-0-N 22-0-0-E");
+	test_lwpoint_to_latlon_assert_format("POINT(21.99999999999 1)",
+		"D-M-S-C", "1-0-0-N 22-0-0-E");
+
 	test_lwpoint_to_latlon_assert_format("POINT(-45.4545 -12.34567)", "DD.DDD", "-12.346 -45.455");
 	test_lwpoint_to_latlon_assert_format("POINT(-45.4545 -12.34567)", "DD.DDD C", "12.346 S 45.455 W");
 	test_lwpoint_to_latlon_assert_format(
diff --git a/liblwgeom/lwprint.c b/liblwgeom/lwprint.c
index 68bb51b2e..c8c58265c 100644
--- a/liblwgeom/lwprint.c
+++ b/liblwgeom/lwprint.c
@@ -332,10 +332,16 @@ static char * lwdouble_to_dms(double val, const char *pos_dir_symbol, const char
 		{
 			/* See if the formatted seconds round up to 60. If so, increment minutes and reset seconds. */
 			round_pow = pow(10, sec_dec_digits);
-			if (floorf(seconds * round_pow) / round_pow >= 60)
+			if (lround(seconds * round_pow) >= 60 * round_pow)
 			{
 				minutes += 1;
 				seconds = 0;
+				/* See if the formatted minutes round up to 60. If so, increment degrees and reset seconds. */
+				if (lround(minutes * round_pow) >= 60 * round_pow)
+				{
+					degrees += 1;
+					minutes = 0;
+				}
 			}
 		}
 	}

-----------------------------------------------------------------------

Summary of changes:
 NEWS                       | 1 +
 liblwgeom/cunit/cu_print.c | 5 +++++
 liblwgeom/lwprint.c        | 8 +++++++-
 3 files changed, 13 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list