]> granicus.if.org Git - postgis/commitdiff
Preprocess input geometry for clipping raster by using the intersection
authorBborie Park <bkpark at ucdavis.edu>
Wed, 24 Oct 2012 22:22:04 +0000 (22:22 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Wed, 24 Oct 2012 22:22:04 +0000 (22:22 +0000)
of the input geometry and the convex hull of the raster. Ticket #1989

git-svn-id: http://svn.osgeo.org/postgis/trunk@10551 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
raster/rt_pg/rtpostgis.sql.in.c

diff --git a/NEWS b/NEWS
index b7b2754ddc532a56930e2ae414ec9266fe6985d2..e12d2ae36129c6e23f0bc782ee82061d489df954 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,7 @@ PostGIS 2.1.0
   - #1364, ST_Union(raster, ...) aggregate function rewritten in C
   - #1661, Add aggregate variant of ST_SameAlignment
   - #1719, Add support for Point and GeometryCollection ST_MakeValid inputs
+  - #1780, support ST_GeoHash for geography
   - #1796, Big performance boost for distance calculations in geography
   - #1802, improved function interruptibility.
   - #1856, tiger geocoder: reverse geocoder rating setting for prefer 
@@ -57,7 +58,8 @@ PostGIS 2.1.0
   - #1938, Refactor basic ST_AddBand to add multiple new bands in one call
   - #1978, wrong answer when calculating length of a closed circular 
            arc (circle)
-  - #1780, support ST_GeoHash for geography
+  - #1989, Preprocess input geometry to just intersection with raster
+           to be clipped
   - #2021, Added multi-band support to ST_Union(raster, ...) aggregate function
   - #2006, better support of ST_Area(geography) over poles and dateline
   - TopologySummary output now includes unregistered layers and a count
index 6f7ec96ba47f57659b15818c7b35debd31214a9d..c21196efa2f754ad2ec8c7cc35c8f76566ae8ef7 100644 (file)
@@ -5461,6 +5461,7 @@ CREATE OR REPLACE FUNCTION st_clip(rast raster, band int, geom geometry, nodatav
        RETURNS raster
        AS $$
        DECLARE
+               g geometry;
                newrast raster;
                geomrast raster;
                numband int;
@@ -5494,7 +5495,8 @@ CREATE OR REPLACE FUNCTION st_clip(rast raster, band int, geom geometry, nodatav
                newextent := CASE WHEN crop THEN 'INTERSECTION' ELSE 'FIRST' END;
 
                -- Convert the geometry to a raster
-               geomrast := ST_AsRaster(geom, rast, ST_BandPixelType(rast, band), 1, newnodataval);
+               g := ST_Intersection(geom, rast::geometry);
+               geomrast := ST_AsRaster(g, rast, ST_BandPixelType(rast, band), 1, newnodataval);
 
                -- Compute the first raster band
                newrast := ST_MapAlgebraExpr(rast, bandstart, geomrast, 1, '[rast1.val]', newpixtype, newextent, newnodataval::text, newnodataval::text, newnodataval);