From: Bborie Park Date: Wed, 24 Oct 2012 22:22:04 +0000 (+0000) Subject: Preprocess input geometry for clipping raster by using the intersection X-Git-Tag: 2.1.0beta2~464 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34ee5c00a7e3edc8da0e22772aa4fc860214b1b9;p=postgis Preprocess input geometry for clipping raster by using the intersection 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 --- diff --git a/NEWS b/NEWS index b7b2754dd..e12d2ae36 100644 --- 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 diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index 6f7ec96ba..c21196efa 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -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);