[postgis-tickets] [SCM] PostGIS branch stable-3.3 updated. 3.3.1-33-ge5a8c35a9

git at osgeo.org git at osgeo.org
Wed Nov 9 22:10:13 PST 2022


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, stable-3.3 has been updated
       via  e5a8c35a948fbf94a316162bd3f9793e5eee4a27 (commit)
      from  5fa9680ae47a26fedd60c4e3922fea1b769e32e2 (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 e5a8c35a948fbf94a316162bd3f9793e5eee4a27
Author: Regina Obe <lr at pcorp.us>
Date:   Thu Nov 10 01:00:34 2022 -0500

    Fix bad rasterization of linestring (Gilles Vuidel)
    References #5084  for PostGIS 3.3.2

diff --git a/NEWS b/NEWS
index 38c7051b0..11e6ef4ab 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,7 @@ PostGIS 3.3.2
   - #5244, postgis_tiger_geocoder update for TIGER 2022 (Regina Obe)
   - #5285, Fix import/export of topologies with names needing quotes (Sandro Santilli)
   - #4988, SFCGAL specify name of unknown type when SFCGAL can't process (Regina Obe)
+  - #5084, Bad rasterization of linestring (Gilles Vuidel)
 
 
 PostGIS 3.3.1
diff --git a/raster/rt_core/rt_raster.c b/raster/rt_core/rt_raster.c
index b5c7956e4..38a821d39 100644
--- a/raster/rt_core/rt_raster.c
+++ b/raster/rt_core/rt_raster.c
@@ -2824,129 +2824,29 @@ rt_raster_gdal_rasterize(
 		_dim[0] == 0 &&
 		_dim[1] == 0
 	) {
-		int result;
-		LWPOLY *epoly = NULL;
-		LWGEOM *lwgeom = NULL;
-		GEOSGeometry *egeom = NULL;
-		GEOSGeometry *geom = NULL;
-
-		RASTER_DEBUG(3, "Testing geometry is properly contained by extent");
-
-		/*
-			see if geometry is properly contained by extent
-			all parts of geometry lies within extent
-		*/
-
-		/* initialize GEOS */
-		initGEOS(rtinfo, lwgeom_geos_error);
-
-		/* convert envelope to geometry */
-		RASTER_DEBUG(4, "Converting envelope to geometry");
-		epoly = rt_util_envelope_to_lwpoly(extent);
-		if (epoly == NULL) {
-			rterror("rt_raster_gdal_rasterize: Could not create envelope's geometry to test if geometry is properly contained by extent");
-
-			OGR_G_DestroyGeometry(src_geom);
-			_rti_rasterize_arg_destroy(arg);
-			/* OGRCleanupAll(); */
-
-			return NULL;
-		}
-
-		egeom = (GEOSGeometry *) LWGEOM2GEOS(lwpoly_as_lwgeom(epoly), 0);
-		lwpoly_free(epoly);
-
-		/* convert WKB to geometry */
-		RASTER_DEBUG(4, "Converting WKB to geometry");
-		lwgeom = lwgeom_from_wkb(wkb, wkb_len, LW_PARSER_CHECK_NONE);
-		geom = (GEOSGeometry *) LWGEOM2GEOS(lwgeom, 0);
-		lwgeom_free(lwgeom);
-
-		result = GEOSRelatePattern(egeom, geom, "T**FF*FF*");
-		GEOSGeom_destroy(geom);
-		GEOSGeom_destroy(egeom);
-
-		if (result == 2) {
-			rterror("rt_raster_gdal_rasterize: Could not test if geometry is properly contained by extent for geometry within extent");
-
-			OGR_G_DestroyGeometry(src_geom);
-			_rti_rasterize_arg_destroy(arg);
-			/* OGRCleanupAll(); */
-
-			return NULL;
-		}
-
-		/* geometry NOT properly contained by extent */
-		if (!result) {
 
 #if POSTGIS_GDAL_VERSION > 18
 
-			/* check alignment flag: grid_xw */
-			if (
-				(NULL == ul_xw && NULL == ul_yw) &&
-				(NULL != grid_xw && NULL != grid_yw) &&
-				FLT_NEQ(*grid_xw, extent.MinX)
-			) {
-				/* do nothing */
-				RASTER_DEBUG(3, "Skipping extent adjustment on X-axis due to upcoming alignment");
-			}
-			else {
-				RASTER_DEBUG(3, "Adjusting extent for GDAL > 1.8 by half the scale on X-axis");
-				extent.MinX -= (_scale[0] / 2.);
-				extent.MaxX += (_scale[0] / 2.);
-			}
+		RASTER_DEBUG(3, "Adjusting extent for GDAL > 1.8 by half the scale on X-axis");
+		extent.MinX -= (_scale[0] / 2.);
+		extent.MaxX += (_scale[0] / 2.);
 
-			/* check alignment flag: grid_yw */
-			if (
-				(NULL == ul_xw && NULL == ul_yw) &&
-				(NULL != grid_xw && NULL != grid_yw) &&
-				FLT_NEQ(*grid_yw, extent.MaxY)
-			) {
-				/* do nothing */
-				RASTER_DEBUG(3, "Skipping extent adjustment on Y-axis due to upcoming alignment");
-			}
-			else {
-				RASTER_DEBUG(3, "Adjusting extent for GDAL > 1.8 by half the scale on Y-axis");
-				extent.MinY -= (_scale[1] / 2.);
-				extent.MaxY += (_scale[1] / 2.);
-			}
+		RASTER_DEBUG(3, "Adjusting extent for GDAL > 1.8 by half the scale on Y-axis");
+		extent.MinY -= (_scale[1] / 2.);
+		extent.MaxY += (_scale[1] / 2.);
 
 #else
 
-			/* check alignment flag: grid_xw */
-			if (
-				(NULL == ul_xw && NULL == ul_yw) &&
-				(NULL != grid_xw && NULL != grid_yw) &&
-				FLT_NEQ(*grid_xw, extent.MinX)
-			) {
-				/* do nothing */
-				RASTER_DEBUG(3, "Skipping extent adjustment on X-axis due to upcoming alignment");
-			}
-			else {
-				RASTER_DEBUG(3, "Adjusting extent for GDAL <= 1.8 by the scale on X-axis");
-				extent.MinX -= _scale[0];
-				extent.MaxX += _scale[0];
-			}
-
+		RASTER_DEBUG(3, "Adjusting extent for GDAL <= 1.8 by the scale on X-axis");
+		extent.MinX -= _scale[0];
+		extent.MaxX += _scale[0];
 
-			/* check alignment flag: grid_yw */
-			if (
-				(NULL == ul_xw && NULL == ul_yw) &&
-				(NULL != grid_xw && NULL != grid_yw) &&
-				FLT_NEQ(*grid_yw, extent.MaxY)
-			) {
-				/* do nothing */
-				RASTER_DEBUG(3, "Skipping extent adjustment on Y-axis due to upcoming alignment");
-			}
-			else {
-				RASTER_DEBUG(3, "Adjusting extent for GDAL <= 1.8 by the scale on Y-axis");
-				extent.MinY -= _scale[1];
-				extent.MaxY += _scale[1];
-			}
+		RASTER_DEBUG(3, "Adjusting extent for GDAL <= 1.8 by the scale on Y-axis");
+		extent.MinY -= _scale[1];
+		extent.MaxY += _scale[1];
 
 #endif
 
-		}
 
 		RASTER_DEBUGF(3, "Adjusted extent: %f, %f, %f, %f",
 			extent.MinX, extent.MinY, extent.MaxX, extent.MaxY);
diff --git a/raster/test/regress/rt_asraster.sql b/raster/test/regress/rt_asraster.sql
index 88c58f091..6a25fd448 100644
--- a/raster/test/regress/rt_asraster.sql
+++ b/raster/test/regress/rt_asraster.sql
@@ -499,6 +499,9 @@ FROM (
 	ORDER BY d.rid
 ) foo;
 
+SELECT '#5084' As ticket, count(dp.geom)
+FROM ST_DumpAsPolygons(ST_AsRaster('LINESTRING(986015.7 6720291.2,986024.3 6720347,986028 6720417.4,986025.6 6720474.3)'::geometry, 2::double precision, 2, 0, 0)) AS dp;
+
 DELETE FROM "spatial_ref_sys" WHERE srid = 992163;
 DELETE FROM "spatial_ref_sys" WHERE srid = 993309;
 DELETE FROM "spatial_ref_sys" WHERE srid = 993310;
diff --git a/raster/test/regress/rt_asraster_expected b/raster/test/regress/rt_asraster_expected
index 79b1cd977..1e8fef17d 100644
--- a/raster/test/regress/rt_asraster_expected
+++ b/raster/test/regress/rt_asraster_expected
@@ -62,3 +62,4 @@ NOTICE:  The rasters have different scales on the X axis
 4.7|992163|150|117|1|1000.000|-1000.000|0.000|0.000|-1898000.000|-412000.000|16BUI|0.000|t|13.000|13.000|t
 4.8|993310|142|88|1|1000.000|-1000.000|0.000|0.000|-176000.000|115000.000|16BUI|0.000|t|13.000|13.000|f
 4.9|993310|142|88|1|1000.000|-1000.000|0.000|0.000|-176453.000|115987.000|16BUI|0.000|t|13.000|13.000|f
+#5084|10

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

Summary of changes:
 NEWS                                     |   1 +
 raster/rt_core/rt_raster.c               | 124 +++----------------------------
 raster/test/regress/rt_asraster.sql      |   3 +
 raster/test/regress/rt_asraster_expected |   1 +
 4 files changed, 17 insertions(+), 112 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list