]> granicus.if.org Git - postgis/commitdiff
shortcut ST_Clip if clipping geometry extent fully contains raster extent. Ticket...
authorBborie Park <bkpark at ucdavis.edu>
Sun, 27 Jul 2014 17:06:54 +0000 (17:06 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Sun, 27 Jul 2014 17:06:54 +0000 (17:06 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@12833 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
raster/rt_pg/rtpostgis.sql.in

diff --git a/NEWS b/NEWS
index 890f3b2ff41da05e010519292c7efc93085f6fec..b59c50e2f7d80b69bc5358482d90e5ad2ac31269 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -56,6 +56,8 @@ PostGIS 2.2.0
   - #2754, SFCGAL can now be installed with CREATE EXTENSION
        Vincent Mora (Oslandia)
   - #2828, Convert ST_Envelope(raster) from SQL to C
+  - #2829, Shortcut ST_Clip(raster) if geometry fully contains the raster
+           and no NODATA specified
 
  * Bug Fixes *
 
index f90eee62b2a9cd815c3f8d91930c00fb7bf64e63..205bd907eb5b4334176c7b869cf63995f16dbccd 100644 (file)
@@ -6602,7 +6602,7 @@ CREATE AGGREGATE st_union(raster, text) (
 -- ST_Clip
 -----------------------------------------------------------------------
 
-CREATE OR REPLACE FUNCTION st_clip(
+CREATE OR REPLACE FUNCTION _st_clip(
        rast raster, nband integer[],
        geom geometry,
        nodataval double precision[] DEFAULT NULL, crop boolean DEFAULT TRUE
@@ -6611,6 +6611,25 @@ CREATE OR REPLACE FUNCTION st_clip(
        AS 'MODULE_PATHNAME', 'RASTER_clip'
        LANGUAGE 'c' IMMUTABLE;
 
+CREATE OR REPLACE FUNCTION st_clip(
+       rast raster, nband integer[],
+       geom geometry,
+       nodataval double precision[] DEFAULT NULL, crop boolean DEFAULT TRUE
+)
+       RETURNS raster
+       AS $$
+       DECLARE
+               contains boolean;
+       BEGIN
+               -- short-cut if geometry's extent fully contains raster's extent
+               IF (nodataval IS NULL OR array_length(nodataval, 1) < 1) AND geom ~ ST_Envelope(rast) THEN
+                       RETURN rast;
+               END IF;
+
+               RETURN _ST_Clip($1, $2, $3, $4, $5);
+       END;
+       $$ LANGUAGE 'plpgsql' IMMUTABLE;
+
 CREATE OR REPLACE FUNCTION st_clip(
        rast raster, nband integer,
        geom geometry,