[SCM] PostGIS branch master updated. 3.5.0alpha2-22-g9425f4a84
git at osgeo.org
git at osgeo.org
Tue Aug 6 14:53:55 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, master has been updated
via 9425f4a84007cd11a2ea989817fb83da2bf8fcb5 (commit)
from 4f33aa5bc0e53d72d4f7442dcf4e6bbbe2905ccc (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 9425f4a84007cd11a2ea989817fb83da2bf8fcb5
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 6b9da1805..f7237b144 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:
liblwgeom/cunit/cu_print.c | 5 +++++
liblwgeom/lwprint.c | 8 +++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list