From 482716f7e5aae12026a56f20684400991f271055 Mon Sep 17 00:00:00 2001 From: Darafei Praliaskouski Date: Tue, 23 Oct 2018 12:58:02 +0000 Subject: [PATCH] [raster] Fix envelope Contains shortcut in ST_Clip Patch by Sai-bot Closes #3457 git-svn-id: http://svn.osgeo.org/postgis/trunk@16940 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 1 + raster/rt_pg/rtpostgis.sql.in | 2 +- raster/test/regress/tickets.sql | 2 ++ raster/test/regress/tickets_expected | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 4cfadd008..7c51b4b65 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ PostGIS 3.0.0 - #4191, Fix undefined behaviour in ptarray_clone_deep (Raúl Marín) - #4211, Fix ST_Subdivide for minimal exterior ring with minimal hole (Darafei Praliaskouski) + - #3457, Fix raster envelope shortcut in ST_Clip (Sai-bot) PostGIS 2.5.0 2018/09/23 diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in index 40b71c0ac..36006a8f9 100644 --- a/raster/rt_pg/rtpostgis.sql.in +++ b/raster/rt_pg/rtpostgis.sql.in @@ -6971,7 +6971,7 @@ CREATE OR REPLACE FUNCTION st_clip( AS $$ BEGIN -- short-cut if geometry's extent fully contains raster's extent - IF (nodataval IS NULL OR array_length(nodataval, 1) < 1) AND geom ~ @extschema@.ST_Envelope(rast) THEN + IF (nodataval IS NULL OR array_length(nodataval, 1) < 1) AND @extschema@.ST_Contains(geom, @extschema@.ST_Envelope(rast)) THEN RETURN rast; END IF; diff --git a/raster/test/regress/tickets.sql b/raster/test/regress/tickets.sql index dd4fe7af8..52d9e05a9 100644 --- a/raster/test/regress/tickets.sql +++ b/raster/test/regress/tickets.sql @@ -121,3 +121,5 @@ SELECT ST_SummaryStats(ST_Clip(ST_MakeEmptyRaster(42, 42, 0, 0, 1.0, 1.0, 0, 0, -- #4102 negative nodata values don't apply on Raspberry Pi SELECT '#4102.1', ST_BandNoDataValue(ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 1, -1, 0, 0, 0), 1, '16BSI', 0, -10), 1) AS rast; SELECT '#4102.2', ST_BandNoDataValue(ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 1, -1, 0, 0, 0), 1, '32BSI', 0, -10), 1) AS rast; + +select '#3457', ST_Area((ST_DumpAsPolygons(ST_Clip(ST_ASRaster(ST_GeomFromText('POLYGON((0 0,100 0,100 100,0 100,0 0))',4326),ST_Addband(ST_MakeEmptyRaster(1,1,0,0,1,-1,0,0,4326),'32BF'::text,0,-1),'32BF'::text,1,-1), ST_GeomFromText('POLYGON((0 0,100 100,100 0,0 0))',4326)))).geom); diff --git a/raster/test/regress/tickets_expected b/raster/test/regress/tickets_expected index 1b1d14ab3..5ac2ac54f 100644 --- a/raster/test/regress/tickets_expected +++ b/raster/test/regress/tickets_expected @@ -16,3 +16,4 @@ NOTICE: Input raster is empty or has no bands. Returning empty raster NOTICE: Invalid band index (must use 1-based). Returning NULL #4102.1|-10 #4102.2|-10 +#3457|4950 -- 2.40.0