From e0905c13d0b1a1b015124a737db8fc048c0cda3d Mon Sep 17 00:00:00 2001 From: Darafei Praliaskouski Date: Sun, 22 Jul 2018 12:22:27 +0000 Subject: [PATCH] Fix TopologyException in Raster Instersection MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Raster _st_intersects was doing ST_Collect of polygons building each pixel, which led to invalid geometry and TopologyException. Thanks Vinícius A.B. Schmidt for reporting and testing solutions. Closes #4132 git-svn-id: http://svn.osgeo.org/postgis/trunk@16660 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 2 ++ raster/rt_pg/rtpostgis.sql.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 2e66607cd..f0ed68f9b 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ New since PostGIS 2.5.0beta1 - #4115, Fix a bug that created MVTs with incorrect property values under parallel plans (Raúl Marín). - #4120, ST_AsMVTGeom: Clip using tile coordinates (Raúl Marín). + - #4132, ST_Intersection on Raster now works without throwing TopologyException + (Vinícius A.B. Schmidt, Darafei Praliaskouski) See PostGIS 2.5.0 section for full details diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in index 018928930..40b71c0ac 100644 --- a/raster/rt_pg/rtpostgis.sql.in +++ b/raster/rt_pg/rtpostgis.sql.in @@ -6434,7 +6434,7 @@ CREATE OR REPLACE FUNCTION _st_intersects(geom geometry, rast raster, nband inte RETURN TRUE; END IF; - SELECT @extschema@.ST_Collect(t.geom) INTO _geom FROM @extschema@.ST_PixelAsPolygons(rast, nband) AS t; + SELECT @extschema@.ST_Buffer(@extschema@.ST_Collect(t.geom), 0) INTO _geom FROM @extschema@.ST_PixelAsPolygons(rast, nband) AS t; RETURN @extschema@.ST_Intersects(geom, _geom); END; $$ LANGUAGE 'plpgsql' IMMUTABLE _PARALLEL -- 2.40.0