]> granicus.if.org Git - postgis/commitdiff
Additional cleanup and validation regarding ticket #1653
authorBborie Park <bkpark at ucdavis.edu>
Fri, 30 Nov 2012 01:13:10 +0000 (01:13 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Fri, 30 Nov 2012 01:13:10 +0000 (01:13 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10770 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
doc/reference_raster.xml
raster/rt_pg/rtpostgis.sql.in.c

diff --git a/NEWS b/NEWS
index 4145de9d895cf62ea191b8827064f12d0adbbe72..f5e061d8b668c18d90cbd5940cb8eade2f4b0c88 100644 (file)
--- 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
 
index 5ab901685495f7611dae8e7a40ec2fd898294f92..d9c0920b7b62e2c51d64992377e3e65037e5a563 100644 (file)
@@ -5430,7 +5430,9 @@ WHERE rid = 2;
                <refentry id="RT_ST_Resample">
                        <refnamediv>
                                <refname>ST_Resample</refname>
-                               <refpurpose>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.</refpurpose>
+                               <refpurpose>
+                                       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.
+                               </refpurpose>
                        </refnamediv>
                
                        <refsynopsisdiv>
@@ -5484,15 +5486,25 @@ WHERE rid = 2;
                        <refsection>
                                <title>Description</title>
                                
-                               <para>Resample a raster using a specified resampling algorithm, new dimensions (width &amp; height), a grid corner (gridx &amp; gridy) and a set of raster georeferencing attributes (scalex, scaley, skewx &amp; skewy) defined or borrowed from another raster.</para>
+                               <para>
+                                       Resample a raster using a specified resampling algorithm, new dimensions (width &amp; height), a grid corner (gridx &amp; gridy) and a set of raster georeferencing attributes (scalex, scaley, skewx &amp; skewy) defined or borrowed from another raster. If using a reference raster, the two rasters must have the same SRID.
+                               </para>
                                
-                               <para>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.</para>
+                               <para>
+                                       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.
+                               </para>
                                
-                               <para>A maxerror percent of 0.125 is used if no <varname>maxerr</varname> is specified.</para>
+                               <para>
+                                       A maxerror percent of 0.125 is used if no <varname>maxerr</varname> is specified.
+                               </para>
                                
-                               <note><para>Refer to: <ulink url="http://www.gdal.org/gdalwarp.html">GDAL Warp resampling methods</ulink> for more details.</para></note>
+                               <note>
+                                       <para>
+                                               Refer to: <ulink url="http://www.gdal.org/gdalwarp.html">GDAL Warp resampling methods</ulink> for more details.
+                                       </para>
+                               </note>
                                <para>Availability: 2.0.0 Requires GDAL 1.6.1+</para>
-                               <para>Changed: 2.1.0 Parameter srid removed. Use ST_Transform() to reproject raster. Works on rasters with no SRID.</para>
+                               <para>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.</para>
                        </refsection>
                                
                        <refsection>
index d2b86578dfdeae62fa239349dcf6cc25f3452253..b3afaf9541a04f82c232b54997935433717bddcb 100644 (file)
@@ -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;