From fac9a0cdada2d1525f7d2484105fb88ecaaa12f5 Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Fri, 30 Nov 2012 01:13:10 +0000 Subject: [PATCH] Additional cleanup and validation regarding ticket #1653 git-svn-id: http://svn.osgeo.org/postgis/trunk@10770 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 3 ++- doc/reference_raster.xml | 24 +++++++++++++++----- raster/rt_pg/rtpostgis.sql.in.c | 39 +++++++++++++++++++++------------ 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/NEWS b/NEWS index 4145de9d8..f5e061d8b 100644 --- a/NEWS +++ b/NEWS @@ -11,7 +11,8 @@ PostGIS 2.1.0 - ST_Hillshade parameters azimuth and altitude are now in degrees instead of radians. - ST_Slope and ST_Aspect return pixel values in degrees instead of radians. - - #1653, Removed srid parameter from ST_Resample(raster). + - #1653, Removed srid parameter from ST_Resample(raster) and variants + with reference raster no longer apply reference raster's SRID. * Deprecated signatures diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index 5ab901685..d9c0920b7 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -5430,7 +5430,9 @@ WHERE rid = 2; ST_Resample - Resample a raster using a specified resampling algorithm, new dimensions, an arbitrary grid corner and a set of raster georeferencing attributes defined or borrowed from another raster. New pixel values are computed using the NearestNeighbor (English or American spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. Default is NearestNeighbor. + + Resample a raster using a specified resampling algorithm, new dimensions, an arbitrary grid corner and a set of raster georeferencing attributes defined or borrowed from another raster. + @@ -5484,15 +5486,25 @@ WHERE rid = 2; Description - Resample a raster using a specified resampling algorithm, new dimensions (width & height), a grid corner (gridx & gridy) and a set of raster georeferencing attributes (scalex, scaley, skewx & skewy) defined or borrowed from another raster. + + Resample a raster using a specified resampling algorithm, new dimensions (width & height), a grid corner (gridx & gridy) and a set of raster georeferencing attributes (scalex, scaley, skewx & skewy) defined or borrowed from another raster. If using a reference raster, the two rasters must have the same SRID. + - New pixel values are computed using the NearestNeighbor (English or American spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. Default is NearestNeighbor which is the fastest but produce the worst interpolation. + + New pixel values are computed using the NearestNeighbor (English or American spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. Default is NearestNeighbor which is the fastest but produce the worst interpolation. + - A maxerror percent of 0.125 is used if no maxerr is specified. + + A maxerror percent of 0.125 is used if no maxerr is specified. + - Refer to: GDAL Warp resampling methods for more details. + + + Refer to: GDAL Warp resampling methods for more details. + + Availability: 2.0.0 Requires GDAL 1.6.1+ - Changed: 2.1.0 Parameter srid removed. Use ST_Transform() to reproject raster. Works on rasters with no SRID. + Changed: 2.1.0 Parameter srid removed. Variants with a reference raster no longer applies the reference raster's SRID. Use ST_Transform() to reproject raster. Works on rasters with no SRID. diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index d2b86578d..b3afaf954 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -2023,26 +2023,37 @@ CREATE OR REPLACE FUNCTION st_resample( RETURNS raster AS $$ DECLARE - dim_x int; - dim_y int; - scale_x double precision; - scale_y double precision; - grid_x double precision; - grid_y double precision; - skew_x double precision; - skew_y double precision; + rastsrid int; + + _srid int; + _dimx int; + _dimy int; + _scalex double precision; + _scaley double precision; + _gridx double precision; + _gridy double precision; + _skewx double precision; + _skewy double precision; BEGIN - SELECT width, height, scalex, scaley, upperleftx, upperlefty, skewx, skewy INTO dim_x, dim_y, scale_x, scale_y, grid_x, grid_y, skew_x, skew_y FROM st_metadata($2); + SELECT srid, width, height, scalex, scaley, upperleftx, upperlefty, skewx, skewy INTO _srid, _dimx, _dimy, _scalex, _scaley, _gridx, _gridy, _skewx, _skewy FROM st_metadata($2); + + rastsrid := ST_SRID($1); + + -- both rasters must have the same SRID + IF (rastsrid != _srid) THEN + RAISE EXCEPTION 'The raster to be resampled has a different SRID from the reference raster'; + RETURN NULL; + END IF; IF usescale IS TRUE THEN - dim_x := NULL; - dim_y := NULL; + _dimx := NULL; + _dimy := NULL; ELSE - scale_x := NULL; - scale_y := NULL; + _scalex := NULL; + _scaley := NULL; END IF; - RETURN _st_gdalwarp($1, $3, $4, NULL, scale_x, scale_y, grid_x, grid_y, skew_x, skew_y, dim_x, dim_y); + RETURN _st_gdalwarp($1, $3, $4, NULL, _scalex, _scaley, _gridx, _gridy, _skewx, _skewy, _dimx, _dimy); END; $$ LANGUAGE 'plpgsql' STABLE STRICT; -- 2.50.1