[postgis-tickets] [SCM] PostGIS branch stable-2.5 updated. 2.5.8-7-g7e1ee433e
git at osgeo.org
git at osgeo.org
Wed Nov 9 22:26:46 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-2.5 has been updated
via 7e1ee433ecb6386de9065f26e266851ec562ca23 (commit)
from ed8942fd34e39f595bdde9d850b51ed5b5c053e0 (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 7e1ee433ecb6386de9065f26e266851ec562ca23
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 2.5.9
diff --git a/NEWS b/NEWS
index 8997e2a4b..435415a1d 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ PostGIS 2.5.9
- #5280, shp2pgsql: Handle load of dbase character fields with no width
specified (Regina Obe)
- #5240, ST_DumpPoints crash with empty polygon (Regina Obe)
+ - #5084, Bad rasterization of linestring (Gilles Vuidel)
PostGIS 2.5.8
2022/08/17
diff --git a/raster/rt_core/rt_raster.c b/raster/rt_core/rt_raster.c
index e46846292..83ef152b3 100644
--- a/raster/rt_core/rt_raster.c
+++ b/raster/rt_core/rt_raster.c
@@ -2719,129 +2719,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 548cc9795..47cdc9536 100644
--- a/raster/test/regress/rt_asraster.sql
+++ b/raster/test/regress/rt_asraster.sql
@@ -496,6 +496,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