[SCM] PostGIS branch master updated. 3.5.0-474-gb66da5a3e
git at osgeo.org
git at osgeo.org
Fri Jul 18 01:05:51 PDT 2025
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 b66da5a3e3c6402d4246ddddbc0da661b857995f (commit)
from 43960094f99294a3e5e62bda1082b2a3a269984e (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 b66da5a3e3c6402d4246ddddbc0da661b857995f
Author: Loïc Bartoletti <loic.bartoletti at oslandia.com>
Date: Thu Jul 17 14:18:51 2025 +0200
fix(SFCGAL): CG_Visibilty returns empty polygon if one input is empty
diff --git a/sfcgal/lwgeom_sfcgal.c b/sfcgal/lwgeom_sfcgal.c
index b50a10c43..cec862018 100644
--- a/sfcgal/lwgeom_sfcgal.c
+++ b/sfcgal/lwgeom_sfcgal.c
@@ -1202,6 +1202,17 @@ sfcgal_visibility_point(PG_FUNCTION_ARGS)
point = POSTGIS2SFCGALGeometry(input1);
PG_FREE_IF_COPY(input1, 1);
+#if POSTGIS_SFCGAL_VERSION < 20200
+ if (gserialized_is_empty(input0) || gserialized_is_empty(input1))
+ {
+ result = sfcgal_polygon_create();
+ output = SFCGALGeometry2POSTGIS(result, 0, srid);
+ sfcgal_geometry_delete(result);
+
+ PG_RETURN_POINTER(output);
+ }
+#endif
+
result = sfcgal_geometry_visibility_point(polygon, point);
sfcgal_geometry_delete(polygon);
sfcgal_geometry_delete(point);
@@ -1241,7 +1252,18 @@ sfcgal_visibility_segment(PG_FUNCTION_ARGS)
pointA = POSTGIS2SFCGALGeometry(input1);
PG_FREE_IF_COPY(input1, 1);
pointB = POSTGIS2SFCGALGeometry(input2);
- PG_FREE_IF_COPY(input1, 2);
+ PG_FREE_IF_COPY(input2, 2);
+
+#if POSTGIS_SFCGAL_VERSION < 20200
+ if (gserialized_is_empty(input0) || gserialized_is_empty(input1) || gserialized_is_empty(input2))
+ {
+ result = sfcgal_polygon_create();
+ output = SFCGALGeometry2POSTGIS(result, 0, srid);
+ sfcgal_geometry_delete(result);
+
+ PG_RETURN_POINTER(output);
+ }
+#endif
result = sfcgal_geometry_visibility_segment(polygon, pointA, pointB);
sfcgal_geometry_delete(polygon);
diff --git a/sfcgal/regress/visibility.sql b/sfcgal/regress/visibility.sql
index 392bd40dd..621467574 100644
--- a/sfcgal/regress/visibility.sql
+++ b/sfcgal/regress/visibility.sql
@@ -2,3 +2,8 @@ SELECT 'Visibility point in polygon', ST_AsText(CG_Visibility('POLYGON((0.0 4.0,
SELECT 'Visibility point in polygon with hole', ST_AsText(CG_Visibility('POLYGON((0.0 4.0,0.0 0.0,3.0 2.0,4.0 0.0,4.0 4.0,1.0 2.0,0.0 4.0),(0.2 1.8,0.9 1.8,0.7 1.2,0.2 1.8))', 'POINT(0.5 2.0)'), 2);
SELECT 'Visibility segment in polygon', ST_AsText(CG_Visibility('POLYGON((0.0 4.0,0.0 0.0,3.0 2.0,4.0 0.0,4.0 4.0,1.0 2.0,0.0 4.0))', 'POINT(1.0 2.0)', 'POINT(4.0 4.0)'), 2);
SELECT 'Visibility segment in polygon with hole', ST_AsText(CG_Visibility('POLYGON((1.0 2.0,12.0 3.0,19.0 -2.0,12.0 6.0,14.0 14.0,9.0 5.0,1.0 2.0),(8.0 3.0,8.0 4.0,10.0 3.0,8.0 3.0),(10.0 6.0,11.0 7.0,11.0 6.0,10.0 6.0))', 'POINT(19.0 -2.0)', 'POINT(12.0 6.0)'), 2);
+SELECT 'Visibility point empty polygon', ST_AsText(CG_Visibility(ST_GeomFromText('POLYGON EMPTY',4326), ST_Point(1,2,4326)));
+SELECT 'Visibility point empty point', ST_AsText(CG_Visibility(ST_GeomFromText('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))',4326), ST_GeomFromText('POINT EMPTY', 4326)));
+SELECT 'Visibility segment empty polygon', ST_AsText(CG_Visibility(ST_GeomFromText('POLYGON EMPTY',4326), ST_Point(1,2,4326) , ST_Point(1,2,4326)));
+SELECT 'Visibility segment empty pointA', ST_AsText(CG_Visibility(ST_GeomFromText('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))',4326), ST_GeomFromText('POINT EMPTY', 4326) , ST_Point(1,2,4326)));
+SELECT 'Visibility segment empty pointB', ST_AsText(CG_Visibility(ST_GeomFromText('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))',4326), ST_Point(1,2,4326), ST_GeomFromText('POINT EMPTY', 4326)));
diff --git a/sfcgal/regress/visibility_expected b/sfcgal/regress/visibility_expected
index b0bc3172b..753d7e8c6 100644
--- a/sfcgal/regress/visibility_expected
+++ b/sfcgal/regress/visibility_expected
@@ -2,3 +2,8 @@ Visibility point in polygon|POLYGON((3 2,1 2,0 4,0 0,3 2))
Visibility point in polygon with hole|POLYGON((0 1.67,0.2 1.8,0.9 1.8,1.93 1.29,3 2,1 2,0 4,0 1.67))
Visibility segment in polygon|POLYGON((4 0,4 4,1 2,0 1.33,0 0,3 2,4 0))
Visibility segment in polygon with hole|POLYGON((19 -2,12 6,14 14,10.43 7.57,11 7,11 6,10 6,9.56 6,9 5,1 2,4.67 2.33,8 4,10 3,9.87 2.81,12 3,19 -2))
+Visibility point empty polygon|POLYGON EMPTY
+Visibility point empty point|POLYGON EMPTY
+Visibility segment empty polygon|POLYGON EMPTY
+Visibility segment empty pointA|POLYGON EMPTY
+Visibility segment empty pointB|POLYGON EMPTY
-----------------------------------------------------------------------
Summary of changes:
sfcgal/lwgeom_sfcgal.c | 24 +++++++++++++++++++++++-
sfcgal/regress/visibility.sql | 5 +++++
sfcgal/regress/visibility_expected | 5 +++++
3 files changed, 33 insertions(+), 1 deletion(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list