[SCM] PostGIS branch master updated. 3.7.0beta1-270-gf03f1cf994

git at osgeo.org git at osgeo.org
Sun Aug 9 08:56:17 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  f03f1cf99496832fbc7d2881f41187124b113718 (commit)
       via  d064fc038ec6fbcecd1375909d6ded791a871f0d (commit)
      from  fa5de5802ba7fcee8ebf4b70d231debf4353bd9a (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 f03f1cf99496832fbc7d2881f41187124b113718
Merge: fa5de5802b d064fc038e
Author: Darafei Praliaskouski <komzpa at gmail.com>
Date:   Sun Aug 9 08:56:15 2026 -0700

    Merge pull request 'raster: document IntersectionFractions float buffer contract' (!676) from Komzpa/postgis:fix/intersection-fractions-float-contract-20260809 into master
    
    ### Motivation
    
    `ST_IntersectionFractions` has been repeatedly flagged as if `GEOSGridIntersectionFractions` wrote double-precision output into the raster band. The GEOS 3.14+ C API is declared with a `float *buf` output parameter, so the existing `PT_32BF` band is the matching raster storage type.
    
    Make that contract harder to misread in source review and static analysis.
    
    ### Description
    
    - Keep the output band as `PT_32BF`.
    - Name the GEOS output buffer as `float *geos_fractions` before calling GEOS.
    - Add a defensive size check that `PT_32BF` matches the GEOS float buffer element size.
    - Expand the nearby comment to say that `PT_64BF`/double would mismatch the GEOS API rather than make the call safer.
    
    No `NEWS` entry: this does not change user-visible behavior; it documents and guards the existing GEOS/PostGIS buffer contract.
    
    ### Validation
    
    - `./autogen.sh && ./configure --with-raster --without-topology --without-protobuf`
    - `git clang-format gitea/master --diff -- raster/rt_core/rt_spatial_relationship.c`
    - `make -C raster/rt_core -j2`
    - `make -C raster/rt_pg -j2`
    - `make -C regress staged-install`
    - `make -C raster/test/regress check TESTS=./rt_intersection_fractions`
    - `git diff --check`
    - `utils/docs/check_news.sh --base-ref gitea/master .`
    
    Reviewed-on: https://gitea.osgeo.org/postgis/postgis/pulls/676


commit d064fc038ec6fbcecd1375909d6ded791a871f0d
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Sun Aug 9 19:31:59 2026 +0400

    raster: document IntersectionFractions float buffer contract

diff --git a/raster/rt_core/rt_spatial_relationship.c b/raster/rt_core/rt_spatial_relationship.c
index 625b2ead26..d1b55eb6a8 100644
--- a/raster/rt_core/rt_spatial_relationship.c
+++ b/raster/rt_core/rt_spatial_relationship.c
@@ -1304,6 +1304,7 @@ rt_raster_intersection_fractions(
 	rt_band band_out = NULL;
 	int band_num;
 	unsigned int width, height;
+	float *geos_fractions = NULL;
 	GEOSGeometry *geos_geom = NULL;
 	int geos_result;
 
@@ -1333,8 +1334,11 @@ rt_raster_intersection_fractions(
 
 	/* Shallow clone a new raster with no bands */
 	rast_out = rt_raster_clone(rast_in, 0);
-	/* GEOSGridIntersectionFractions writes float values into float* buf,
-	 * so the output band must stay PT_32BF rather than PT_64BF. */
+	/*
+	 * GEOSGridIntersectionFractions is declared with a float *buf output
+	 * parameter in the GEOS 3.14+ C API. Keep this band PT_32BF; using
+	 * PT_64BF/double would mismatch the GEOS API rather than make it safer.
+	 */
 	band_num = rt_raster_generate_new_band(
 		rast_out, /* rast */
 		PT_32BF, /* pixel type */
@@ -1350,6 +1354,14 @@ rt_raster_intersection_fractions(
 		rterror("%s: Failed to create output band", __func__);
 		return NULL;
 	}
+	if (rt_pixtype_size(PT_32BF) != (int)sizeof(*geos_fractions))
+	{
+		rt_raster_destroy(rast_out);
+		rterror("%s: PT_32BF size does not match GEOS float buffer", __func__);
+		return NULL;
+	}
+	geos_fractions = rt_band_get_data(band_out);
+	assert(geos_fractions != NULL);
 
 	/* Prepare for GEOS call */
 	/* Initialize GEOS to handle notices and errors */
@@ -1367,12 +1379,7 @@ rt_raster_intersection_fractions(
 
 	/* Call the core GEOS function */
 	geos_result = GEOSGridIntersectionFractions(
-		geos_geom,
-		rast_env.MinX, rast_env.MinY,
-		rast_env.MaxX, rast_env.MaxY,
-		width, height,
-		rt_band_get_data(band_out)
-	);
+	    geos_geom, rast_env.MinX, rast_env.MinY, rast_env.MaxX, rast_env.MaxY, width, height, geos_fractions);
 
 	/* The GEOS geometry is no longer needed after this call, so we can clean it up */
 	GEOSGeom_destroy(geos_geom);

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

Summary of changes:
 raster/rt_core/rt_spatial_relationship.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list