postgis.git / summary / log / commit / refs

commit    b3fbe2cbc20bb7a3f93db65f7bfeefd032f00e37
Author:   Darafei Praliaskouski <me@komzpa.net>
Commit:   Loïc Bartoletti <lbartoletti@noreply.gitea.osgeo.org>
Date:     Mon Jun 08 14:21:49 2026 +0000

    fix: preserve empty NURBS through SFCGAL


liblwgeom/cunit/cu_sfcgal.c | 6 ++++++ liblwgeom/lwgeom_sfcgal.c | 17 +++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/liblwgeom/cunit/cu_sfcgal.c b/liblwgeom/cunit/cu_sfcgal.c index a54bd5218..fd26d58c1 100644 --- a/liblwgeom/cunit/cu_sfcgal.c +++ b/liblwgeom/cunit/cu_sfcgal.c @@ -41,6 +41,9 @@ test_sfcgal_noop(void) "POLYHEDRALSURFACE(((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)),((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)))", "POLYHEDRALSURFACE(((-1 -1 1,-1 2.5 1,2 2 1,2 -1 1,-1 -1 1),(0 0 1,0 1 1,1 1 1,1 0 1,0 0 1),(-0.5 -0.5 1,-0.5 -0.4 1,-0.4 -0.4 1,-0.4 -0.5 1,-0.5 -0.5 1)),((-1 -1 1,-1 2.5 1,2 2 1,2 -1 1,-1 -1 1),(0 0 1,0 1 1,1 1 1,1 0 1,0 0 1),(-0.5 -0.5 1,-0.5 -0.4 1,-0.4 -0.4 1,-0.4 -0.5 1,-0.5 -0.5 1)))", "TIN(((0 0,0 -1,-1 1,0 0)),((0 0,1 0,0 -1,0 0)))", +#if POSTGIS_SFCGAL_VERSION >= 20300 + "NURBSCURVE EMPTY", +#endif #if POSTGIS_SFCGAL_VERSION >= 10500 // Z/M Support "POINTZM(1 2 3 4)", @@ -81,6 +84,9 @@ test_sfcgal_noop(void) "POLYHEDRALSURFACE(((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)),((-1 -1,-1 2.5,2 2,2 -1,-1 -1),(0 0,0 1,1 1,1 0,0 0),(-0.5 -0.5,-0.5 -0.4,-0.4 -0.4,-0.4 -0.5,-0.5 -0.5)))", "POLYHEDRALSURFACE(((-1 -1 1,-1 2.5 1,2 2 1,2 -1 1,-1 -1 1),(0 0 1,0 1 1,1 1 1,1 0 1,0 0 1),(-0.5 -0.5 1,-0.5 -0.4 1,-0.4 -0.4 1,-0.4 -0.5 1,-0.5 -0.5 1)),((-1 -1 1,-1 2.5 1,2 2 1,2 -1 1,-1 -1 1),(0 0 1,0 1 1,1 1 1,1 0 1,0 0 1),(-0.5 -0.5 1,-0.5 -0.4 1,-0.4 -0.4 1,-0.4 -0.5 1,-0.5 -0.5 1)))", "TIN(((0 0,0 -1,-1 1,0 0)),((0 0,1 0,0 -1,0 0)))", +#if POSTGIS_SFCGAL_VERSION >= 20300 + "NURBSCURVE EMPTY", +#endif #if POSTGIS_SFCGAL_VERSION >= 10500 // Z/M Support "POINT(1 2 3 4)", diff --git a/liblwgeom/lwgeom_sfcgal.c b/liblwgeom/lwgeom_sfcgal.c index 9cfdc6f49..6eb27c367 100644 --- a/liblwgeom/lwgeom_sfcgal.c +++ b/liblwgeom/lwgeom_sfcgal.c @@ -358,12 +358,11 @@ ptarray_to_SFCGAL(const POINTARRAY *pa, int type) * curve is created as rational. Temporary SFCGAL point objects are allocated * during construction and freed before returning. * - * @param nurbs PostGIS NURBS curve to convert. Must be non-NULL and contain at - * least one control point. + * @param nurbs PostGIS NURBS curve to convert. Must be non-NULL. * @returns A newly created `sfcgal_geometry_t *` representing the NURBS curve, - * or NULL if `nurbs` is NULL, has no control points, or conversion - * fails. The caller is responsible for deleting the returned geometry - * with `sfcgal_geometry_delete`. + * or NULL if `nurbs` is NULL or conversion fails. Empty NURBS curves + * return an empty SFCGAL NURBS curve. The caller is responsible for + * deleting the returned geometry with `sfcgal_geometry_delete`. */ static sfcgal_geometry_t* lwgeom_nurbs_to_sfcgal_nurbs(const LWNURBSCURVE *nurbs) @@ -375,9 +374,12 @@ lwgeom_nurbs_to_sfcgal_nurbs(const LWNURBSCURVE *nurbs) uint32_t i; POINT4D pt; - if (!nurbs || !nurbs->points || nurbs->points->npoints == 0) + if (!nurbs) return NULL; + if (!nurbs->points || nurbs->points->npoints == 0) + return sfcgal_nurbs_curve_create(); + /* Create array of SFCGAL points from control points */ points = (sfcgal_geometry_t**)lwalloc(sizeof(sfcgal_geometry_t*) * nurbs->points->npoints); @@ -467,6 +469,9 @@ sfcgal_nurbs_to_lwgeom_nurbs(const sfcgal_geometry_t* sfcgal_nurbs, int srid) if (!sfcgal_nurbs) return NULL; + if (sfcgal_geometry_is_empty(sfcgal_nurbs)) + return lwnurbscurve_construct_empty(srid, sfcgal_geometry_is_3d(sfcgal_nurbs), 0); + num_points = sfcgal_nurbs_curve_num_control_points(sfcgal_nurbs); degree = sfcgal_nurbs_curve_degree(sfcgal_nurbs); num_knots = sfcgal_nurbs_curve_num_knots(sfcgal_nurbs); [parent: 656861c3b03c]