[SCM] PostGIS branch master updated. 3.7.0beta1-268-gfa5de5802b
git at osgeo.org
git at osgeo.org
Sun Aug 9 08:19: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 fa5de5802ba7fcee8ebf4b70d231debf4353bd9a (commit)
via 80a8dcabf7d9f0b19abae1d853571473cbd9c075 (commit)
from a269ced55cc38f5114b17d59e2cc874d6c4a60c1 (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 fa5de5802ba7fcee8ebf4b70d231debf4353bd9a
Merge: a269ced55c 80a8dcabf7
Author: Darafei Praliaskouski <komzpa at gmail.com>
Date: Sun Aug 9 08:19:51 2026 -0700
Merge pull request 'Fix ST_Normalize TIN child normalization' (!675) from Komzpa/postgis:fix/st-normalize-tin-20260809 into master
## Summary
- keep ST_Normalize from placing non-TRIANGLE children back into TIN collections
- fall back to the original TRIANGLE when GEOS normalization returns a polygon shape that cannot be represented as a TRIANGLE
- add a regression test for malformed WKB TRIANGLE input inside a TIN
## Validation
- ./autogen.sh && ./configure --without-raster --without-topology --without-protobuf
- make -C liblwgeom -j2
- make -C postgis -j2
- make -C doc comments
- make -C regress staged-install
- make -C regress check TESTS=./core/normalize
- git diff --check
- git clang-format gitea/master --diff -- liblwgeom/lwgeom_geos.c
- utils/docs/check_news.sh --base-ref gitea/master .
Reviewed-on: https://gitea.osgeo.org/postgis/postgis/pulls/675
commit 80a8dcabf7d9f0b19abae1d853571473cbd9c075
Author: Darafei Praliaskouski <me at komzpa.net>
Date: Sun Aug 9 18:48:24 2026 +0400
Fix ST_Normalize TIN child normalization
diff --git a/NEWS b/NEWS
index 320f9e7ab2..0991688ce2 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ These are only changes since 3.7.0beta1.
* Bug Fixes *
+ - GT-675, Preserve TRIANGLE children while normalizing malformed TINs
+ (Darafei Praliaskouski)
- GT-671, Harden extension install and upgrade SQL against attacker-controlled
object resolution in writable schemas
(reported by Eric Ridge, PlanetScale;
diff --git a/liblwgeom/lwgeom_geos.c b/liblwgeom/lwgeom_geos.c
index 8bf2261591..a1fadbec06 100644
--- a/liblwgeom/lwgeom_geos.c
+++ b/liblwgeom/lwgeom_geos.c
@@ -682,22 +682,31 @@ lwgeom_compare_by_xdr_ewkb(const void *a, const void *b)
}
static LWGEOM *
-lwgeom_normalized_polygon_to_triangle(LWGEOM *geom)
+lwgeom_normalized_triangle_or_clone(const LWGEOM *triangle_in, LWGEOM *normalized)
{
LWPOLY *poly;
LWTRIANGLE *triangle;
POINTARRAY *points;
- if (!geom || geom->type != POLYGONTYPE)
- return geom;
+ if (normalized && normalized->type == TRIANGLETYPE)
+ return normalized;
- poly = lwgeom_as_lwpoly(geom);
- if (poly->nrings != 1 || !poly->rings[0] || poly->rings[0]->npoints != 4)
- return geom;
+ if (!normalized || normalized->type != POLYGONTYPE)
+ {
+ lwgeom_free(normalized);
+ return lwgeom_clone_deep(triangle_in);
+ }
+
+ poly = lwgeom_as_lwpoly(normalized);
+ if (poly->nrings != 1 || !poly->rings[0])
+ {
+ lwgeom_free(normalized);
+ return lwgeom_clone_deep(triangle_in);
+ }
points = ptarray_clone_deep(poly->rings[0]);
triangle = lwtriangle_construct(poly->srid, NULL, points);
- lwgeom_free(geom);
+ lwgeom_free(normalized);
return lwtriangle_as_lwgeom(triangle);
}
@@ -717,7 +726,7 @@ lwgeom_normalize_lwgeom(const LWGEOM *geom)
normalized = lwgeom_normalize(col->geoms[i]);
if (col->type == TINTYPE && col->geoms[i]->type == TRIANGLETYPE)
- normalized = lwgeom_normalized_polygon_to_triangle(normalized);
+ normalized = lwgeom_normalized_triangle_or_clone(col->geoms[i], normalized);
lwgeom_free(col->geoms[i]);
col->geoms[i] = normalized;
diff --git a/regress/core/normalize.sql b/regress/core/normalize.sql
index b3998aa3b2..30d7a21d52 100644
--- a/regress/core/normalize.sql
+++ b/regress/core/normalize.sql
@@ -17,3 +17,24 @@ select 4, GeometryType(ST_Normalize(
select 5, GeometryType(ST_GeometryN(ST_Normalize(
'GEOMETRYCOLLECTION(POLYHEDRALSURFACE(((0 0,2 0,0 2,0 0))))'
::geometry), 1));
+
+with normalized as (
+ select ST_Normalize(ST_GeomFromWKB(decode(
+ '0110000000010000000111000000010000000500000000000000000000000000000000000000000000000000f03f0000000000000000000000000000f03f000000000000f03f0000000000000000000000000000f03f00000000000000000000000000000000',
+ 'hex'))) as geom
+)
+select 6, GeometryType(normalized.geom), GeometryType((dumped).geom)
+from normalized
+cross join lateral ST_Dump(normalized.geom) as dumped;
+
+with normalized as (
+ select ST_Normalize(ST_GeomFromWKB(decode(
+ '0110000000010000000111000000010000000500000000000000000000000000000000000000000000000000f03f0000000000000000000000000000f03f000000000000f03f0000000000000000000000000000f03f00000000000000000000000000000000',
+ 'hex'))) as geom
+), rotated as (
+ select ST_Normalize(ST_GeomFromWKB(decode(
+ '01100000000100000001110000000100000005000000000000000000f03f000000000000f03f000000000000f03f0000000000000000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f000000000000f03f',
+ 'hex'))) as geom
+)
+select 7, ST_AsEWKB(normalized.geom) = ST_AsEWKB(rotated.geom)
+from normalized, rotated;
diff --git a/regress/core/normalize_expected b/regress/core/normalize_expected
index 92ce31db3f..3070e4c875 100644
--- a/regress/core/normalize_expected
+++ b/regress/core/normalize_expected
@@ -3,3 +3,5 @@
3|POLYHEDRALSURFACE
4|TIN
5|POLYHEDRALSURFACE
+6|TIN|TRIANGLE
+7|t
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 ++
liblwgeom/lwgeom_geos.c | 25 +++++++++++++++++--------
regress/core/normalize.sql | 21 +++++++++++++++++++++
regress/core/normalize_expected | 2 ++
4 files changed, 42 insertions(+), 8 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list