[SCM] PostGIS branch master updated. 3.6.0rc2-545-g5ec62d698

git at osgeo.org git at osgeo.org
Wed Jun 17 11:45:59 PDT 2026


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  5ec62d6985632cc603289b2e7af5efa693d683ca (commit)
       via  435ad25bf7d4e27e1fe4f583a7bdaf19d4cb3f32 (commit)
       via  d0a4c994ad7291cf4bf85ee556a43a8c3af43b64 (commit)
       via  d01c6a3d91ab6018daf086cde59e0e23faaa9389 (commit)
       via  52eb39e6c6fea9ae4aef600f171f6d9aa38ee561 (commit)
      from  d622df60655e5c4ba4cd77dcfdf07b76c47b4016 (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 5ec62d6985632cc603289b2e7af5efa693d683ca
Merge: d622df606 435ad25bf
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Wed Jun 17 22:43:02 2026 +0400

    Merge remote-tracking branch 'gh/pr/885/head'


commit 435ad25bf7d4e27e1fe4f583a7bdaf19d4cb3f32
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Wed Jun 17 01:22:25 2026 +0400

    test: place GMP libs after liblwgeom

diff --git a/NEWS b/NEWS
index 443712616..54811e708 100644
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,8 @@ To take advantage of all postgis_sfcgal extension features SFCGAL 2.3+ is needed
 
 * Bug Fixes *
 
+ - GH-885, [topology] Avoid GMP overflow in ring orientation for very large
+          finite coordinates (Darafei Praliaskouski)
  - Build PostgreSQL extension modules with `-fno-semantic-interposition` when
           available so LTO can optimize same-DSO calls to exported PostGIS
           entry points directly instead of routing through the module PLT; in
diff --git a/liblwgeom/cunit/Makefile.in b/liblwgeom/cunit/Makefile.in
index 6a206e9b2..3999c5523 100644
--- a/liblwgeom/cunit/Makefile.in
+++ b/liblwgeom/cunit/Makefile.in
@@ -22,7 +22,8 @@ LIBTOOL = @LIBTOOL@
 CUNIT_LDFLAGS=@CUNIT_LDFLAGS@
 CUNIT_CPPFLAGS = -I$(srcdir)/.. -I$(builddir)/.. @CUNIT_CPPFLAGS@ @CPPFLAGS@
 CFLAGS=$(CUNIT_CPPFLAGS) @CFLAGS@
-LDFLAGS = @GEOS_LDFLAGS@ @PROJ_LDFLAGS@ @GMP_LIBS@ $(CUNIT_LDFLAGS)
+LDFLAGS = @GEOS_LDFLAGS@ @PROJ_LDFLAGS@ $(CUNIT_LDFLAGS)
+LIBLWGEOM_LDFLAGS = @GMP_LIBS@
 
 VPATH = $(srcdir)
 
@@ -108,7 +109,7 @@ endif
 
 # Build the main unit test executable
 cu_tester: ../liblwgeom.la $(OBJS) cu_tester.h
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) -static ../liblwgeom.la
+	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) -static ../liblwgeom.la $(LIBLWGEOM_LDFLAGS)
 
 # Command to build each of the .o files
 $(OBJS): %.o: %.c

commit d0a4c994ad7291cf4bf85ee556a43a8c3af43b64
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Wed Jun 17 00:36:20 2026 +0400

    test: link CUnit GMP libs through LDFLAGS

diff --git a/liblwgeom/cunit/Makefile.in b/liblwgeom/cunit/Makefile.in
index 65c05d890..6a206e9b2 100644
--- a/liblwgeom/cunit/Makefile.in
+++ b/liblwgeom/cunit/Makefile.in
@@ -22,7 +22,7 @@ LIBTOOL = @LIBTOOL@
 CUNIT_LDFLAGS=@CUNIT_LDFLAGS@
 CUNIT_CPPFLAGS = -I$(srcdir)/.. -I$(builddir)/.. @CUNIT_CPPFLAGS@ @CPPFLAGS@
 CFLAGS=$(CUNIT_CPPFLAGS) @CFLAGS@
-LDFLAGS = @GEOS_LDFLAGS@ @PROJ_LDFLAGS@ $(CUNIT_LDFLAGS)
+LDFLAGS = @GEOS_LDFLAGS@ @PROJ_LDFLAGS@ @GMP_LIBS@ $(CUNIT_LDFLAGS)
 
 VPATH = $(srcdir)
 
@@ -108,7 +108,7 @@ endif
 
 # Build the main unit test executable
 cu_tester: ../liblwgeom.la $(OBJS) cu_tester.h
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) -static ../liblwgeom.la @GMP_LIBS@
+	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) -static ../liblwgeom.la
 
 # Command to build each of the .o files
 $(OBJS): %.o: %.c

commit d01c6a3d91ab6018daf086cde59e0e23faaa9389
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Wed Jun 17 00:10:33 2026 +0400

    liblwgeom: link CUnit tester with GMP

diff --git a/liblwgeom/cunit/Makefile.in b/liblwgeom/cunit/Makefile.in
index 14e41aed3..65c05d890 100644
--- a/liblwgeom/cunit/Makefile.in
+++ b/liblwgeom/cunit/Makefile.in
@@ -108,7 +108,7 @@ endif
 
 # Build the main unit test executable
 cu_tester: ../liblwgeom.la $(OBJS) cu_tester.h
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) -static ../liblwgeom.la
+	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) -static ../liblwgeom.la @GMP_LIBS@
 
 # Command to build each of the .o files
 $(OBJS): %.o: %.c

commit 52eb39e6c6fea9ae4aef600f171f6d9aa38ee561
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Thu Jun 11 07:43:43 2026 +0400

    Avoid GMP overflow in topology ring orientation

diff --git a/liblwgeom/cunit/Makefile.in b/liblwgeom/cunit/Makefile.in
index 791be060e..14e41aed3 100644
--- a/liblwgeom/cunit/Makefile.in
+++ b/liblwgeom/cunit/Makefile.in
@@ -58,6 +58,7 @@ OBJS=	\
 	cu_split.o \
 	cu_stringbuffer.o \
 	cu_triangulate.o \
+	cu_topo.o \
 	cu_homogenize.o \
 	cu_force_dims.o \
 	cu_force_sfs.o \
diff --git a/liblwgeom/cunit/cu_tester.c b/liblwgeom/cunit/cu_tester.c
index a32c3f41a..33c1aa26f 100644
--- a/liblwgeom/cunit/cu_tester.c
+++ b/liblwgeom/cunit/cu_tester.c
@@ -72,6 +72,7 @@ extern void sfcgal_suite_setup(void);
 extern void split_suite_setup(void);
 extern void stringbuffer_suite_setup(void);
 extern void tree_suite_setup(void);
+extern void topo_suite_setup(void);
 extern void triangulate_suite_setup(void);
 extern void varint_suite_setup(void);
 extern void wkt_out_suite_setup(void);
@@ -128,6 +129,7 @@ PG_SuiteSetup setupfuncs[] = {algorithms_suite_setup,
 			      stringbuffer_suite_setup,
 			      surface_suite_setup,
 			      tree_suite_setup,
+			      topo_suite_setup,
 			      triangulate_suite_setup,
 			      twkb_out_suite_setup,
 			      varint_suite_setup,
diff --git a/liblwgeom/cunit/cu_topo.c b/liblwgeom/cunit/cu_topo.c
new file mode 100644
index 000000000..490b95058
--- /dev/null
+++ b/liblwgeom/cunit/cu_topo.c
@@ -0,0 +1,55 @@
+/**********************************************************************
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.net
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ *
+ **********************************************************************/
+
+#include "CUnit/Basic.h"
+#include "CUnit/CUnit.h"
+
+#include "liblwgeom_internal.h"
+#include "topo/liblwgeom_topo.h"
+#include "cu_tester.h"
+
+static LWGEOM *
+lwgeom_from_text(const char *str)
+{
+	LWGEOM_PARSER_RESULT r;
+	if (LW_FAILURE == lwgeom_parse_wkt(&r, (char *)str, LW_PARSER_CHECK_NONE))
+		return NULL;
+	return r.geom;
+}
+
+static void
+test_lwt_IsTopoRingCCW_large_finite_coordinates(void)
+{
+	LWGEOM *geom = lwgeom_from_text("POLYGON((0 1e308,1e308 0,0 0,0 1e308))");
+	LWPOLY *poly;
+
+	CU_ASSERT_PTR_NOT_NULL(geom);
+	if (!geom)
+		return;
+
+	poly = lwgeom_as_lwpoly(geom);
+	CU_ASSERT_PTR_NOT_NULL(poly);
+	if (!poly)
+	{
+		lwgeom_free(geom);
+		return;
+	}
+
+	CU_ASSERT_EQUAL(lwt_IsTopoRingCCW(poly->rings[0]), LW_FALSE);
+
+	lwgeom_free(geom);
+}
+
+void
+topo_suite_setup(void)
+{
+	CU_pSuite suite = CU_add_suite("topology", NULL, NULL);
+	PG_ADD_TEST(suite, test_lwt_IsTopoRingCCW_large_finite_coordinates);
+}
diff --git a/liblwgeom/topo/lwgeom_topo.c b/liblwgeom/topo/lwgeom_topo.c
index 6d0144bb9..c7bfe1cee 100644
--- a/liblwgeom/topo/lwgeom_topo.c
+++ b/liblwgeom/topo/lwgeom_topo.c
@@ -38,6 +38,7 @@
 #include <gmp.h>
 
 #include <inttypes.h>
+#include <math.h>
 
 static bool
 _lwt_describe_point(const LWPOINT *pt, char *buf, size_t bufsize)
@@ -1888,27 +1889,49 @@ lwt_IsTopoRingCCW(const POINTARRAY *pa)
   const POINT2D *P3;
   mpf_t sum;
   mpf_t tmp;
-  double x0, x, y1, y2;
+  mpf_t x0;
+  mpf_t x;
+  mpf_t dy;
   uint32_t i;
   int ret;
 
   if (! pa || pa->npoints < 3 )
     return 0;
 
-  mpf_init2(sum, 64);
-  mpf_init2(tmp, 64);
-  mpf_set_d(sum, 0.0);
-
   P1 = getPoint2d_cp(pa, 0);
   P2 = getPoint2d_cp(pa, 1);
-  x0 = P1->x;
+
+  if (!isfinite(P1->x) || !isfinite(P1->y) || !isfinite(P2->x) || !isfinite(P2->y))
+	  return ptarray_isccw(pa);
+
+  mpf_init2(sum, 64);
+  mpf_init2(tmp, 64);
+  mpf_init2(x0, 64);
+  mpf_init2(x, 64);
+  mpf_init2(dy, 64);
+  mpf_set_d(sum, 0.0);
+  mpf_set_d(x0, P1->x);
+
   for ( i = 2; i < pa->npoints; i++ )
   {
     P3 = getPoint2d_cp(pa, i);
-    x = P2->x - x0;
-    y1 = P3->y;
-    y2 = P1->y;
-    mpf_set_d(tmp, x * (y2-y1));
+
+    if (!isfinite(P3->x) || !isfinite(P3->y))
+    {
+	    mpf_clear(dy);
+	    mpf_clear(x);
+	    mpf_clear(x0);
+	    mpf_clear(tmp);
+	    mpf_clear(sum);
+	    return ptarray_isccw(pa);
+    }
+
+    mpf_set_d(x, P2->x);
+    mpf_sub(x, x, x0);
+    mpf_set_d(dy, P1->y);
+    mpf_set_d(tmp, P3->y);
+    mpf_sub(dy, dy, tmp);
+    mpf_mul(tmp, x, dy);
     mpf_add(sum, sum, tmp);
     P1 = P2;
     P2 = P3;
@@ -1916,6 +1939,9 @@ lwt_IsTopoRingCCW(const POINTARRAY *pa)
 
   ret = mpf_cmp_ui(sum, 0) < 0;
 
+  mpf_clear(dy);
+  mpf_clear(x);
+  mpf_clear(x0);
   mpf_clear(tmp);
   mpf_clear(sum);
 

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

Summary of changes:
 NEWS                         |  2 ++
 liblwgeom/cunit/Makefile.in  |  4 +++-
 liblwgeom/cunit/cu_tester.c  |  2 ++
 liblwgeom/cunit/cu_topo.c    | 55 ++++++++++++++++++++++++++++++++++++++++++++
 liblwgeom/topo/lwgeom_topo.c | 42 ++++++++++++++++++++++++++-------
 5 files changed, 96 insertions(+), 9 deletions(-)
 create mode 100644 liblwgeom/cunit/cu_topo.c


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list