[postgis-tickets] [SCM] PostGIS branch stable-3.1 updated. 3.1.7-24-g110fae45f
git at osgeo.org
git at osgeo.org
Wed Nov 9 22:17:32 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.1 has been updated
via 110fae45f3a779cb3f38edf6a91fc34ea70fc895 (commit)
from a6966410b0f972577a958825d38902100cd0129d (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 110fae45f3a779cb3f38edf6a91fc34ea70fc895
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.1.8
diff --git a/NEWS b/NEWS
index 20ba00c1c..6a074b6b6 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ YYYY/MM/DD
- #5241, Crash on ST_SnapToGrid with empty multis (Regina Obe)
- #5234, Fix 2.5d topology building regression (Sandro Santilli)
- #5280, Handle load of dbase character fields with no width specified (Regina Obe)
+ - #5084, Bad rasterization of linestring (Gilles Vuidel)
PostGIS 3.1.7
2022/08/18
diff --git a/raster/rt_core/rt_raster.c b/raster/rt_core/rt_raster.c
index e75a89b09..f99fd9f66 100644
--- a/raster/rt_core/rt_raster.c
+++ b/raster/rt_core/rt_raster.c
@@ -2697,129 +2697,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