]> granicus.if.org Git - postgis/commitdiff
Renamed RASTER_resample() to RASTER_GDALWarp() and adjusted SQL
authorBborie Park <bkpark at ucdavis.edu>
Thu, 29 Nov 2012 18:59:13 +0000 (18:59 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Thu, 29 Nov 2012 18:59:13 +0000 (18:59 +0000)
functions as needed. Next is to audit and possibly refactor those
functions that make use of RASTER_resample().

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

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

index 0e4463d401fcdc2302333c9585db79098121849c..cf553e6732a60adec35821d3a9dd33a86061c3ce 100644 (file)
@@ -300,8 +300,8 @@ Datum RASTER_getGDALDrivers(PG_FUNCTION_ARGS);
 /* rasterize a geometry */
 Datum RASTER_asRaster(PG_FUNCTION_ARGS);
 
-/* resample a raster */
-Datum RASTER_resample(PG_FUNCTION_ARGS);
+/* warp a raster using GDAL Warp API */
+Datum RASTER_GDALWarp(PG_FUNCTION_ARGS);
 
 /* get raster's meta data */
 Datum RASTER_metadata(PG_FUNCTION_ARGS);
@@ -11174,10 +11174,10 @@ Datum RASTER_asRaster(PG_FUNCTION_ARGS)
 }
 
 /**
- * Resample a raster
+ * warp a raster using GDAL Warp API
  */
-PG_FUNCTION_INFO_V1(RASTER_resample);
-Datum RASTER_resample(PG_FUNCTION_ARGS)
+PG_FUNCTION_INFO_V1(RASTER_GDALWarp);
+Datum RASTER_GDALWarp(PG_FUNCTION_ARGS)
 {
        rt_pgraster *pgraster = NULL;
        rt_pgraster *pgrast = NULL;
@@ -11210,7 +11210,7 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
        int *dim_x = NULL;
        int *dim_y = NULL;
 
-       POSTGIS_RT_DEBUG(3, "RASTER_resample: Starting");
+       POSTGIS_RT_DEBUG(3, "RASTER_GDALWarp: Starting");
 
        /* pgraster is null, return null */
        if (PG_ARGISNULL(0))
@@ -11220,7 +11220,7 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
        /* raster */
        raster = rt_raster_deserialize(pgraster, FALSE);
        if (!raster) {
-               elog(ERROR, "RASTER_resample: Could not deserialize raster");
+               elog(ERROR, "RASTER_GDALWarp: Could not deserialize raster");
                PG_FREE_IF_COPY(pgraster, 0);
                PG_RETURN_NULL();
        }
@@ -11243,7 +11243,7 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
        /* source srid */
        src_srid = rt_raster_get_srid(raster);
        if (clamp_srid(src_srid) == SRID_UNKNOWN) {
-               elog(ERROR, "RASTER_resample: Input raster has unknown (%d) SRID", src_srid);
+               elog(ERROR, "RASTER_GDALWarp: Input raster has unknown (%d) SRID", src_srid);
                rt_raster_destroy(raster);
                PG_FREE_IF_COPY(pgraster, 0);
                PG_RETURN_NULL();
@@ -11254,7 +11254,7 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
        if (!PG_ARGISNULL(3)) {
                dst_srid = PG_GETARG_INT32(3);
                if (clamp_srid(dst_srid) == SRID_UNKNOWN) {
-                       elog(ERROR, "RASTER_resample: %d is an invalid target SRID", dst_srid);
+                       elog(ERROR, "RASTER_GDALWarp: %d is an invalid target SRID", dst_srid);
                        rt_raster_destroy(raster);
                        PG_FREE_IF_COPY(pgraster, 0);
                        PG_RETURN_NULL();
@@ -11362,7 +11362,7 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
        /* source srs */
        src_srs = rtpg_getSR(src_srid);
        if (NULL == src_srs) {
-               elog(ERROR, "RASTER_resample: Input raster has unknown SRID (%d)", src_srid);
+               elog(ERROR, "RASTER_GDALWarp: Input raster has unknown SRID (%d)", src_srid);
                rt_raster_destroy(raster);
                PG_FREE_IF_COPY(pgraster, 0);
                PG_RETURN_NULL();
@@ -11373,7 +11373,7 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
        if (clamp_srid(dst_srid) != SRID_UNKNOWN) {
                dst_srs = rtpg_getSR(dst_srid);
                if (NULL == dst_srs) {
-                       elog(ERROR, "RASTER_resample: Target SRID (%d) is unknown", dst_srid);
+                       elog(ERROR, "RASTER_GDALWarp: Target SRID (%d) is unknown", dst_srid);
                        if (NULL != src_srs) pfree(src_srs);
                        rt_raster_destroy(raster);
                        PG_FREE_IF_COPY(pgraster, 0);
@@ -11407,7 +11407,7 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
 
        if (NULL == pgrast) PG_RETURN_NULL();
 
-       POSTGIS_RT_DEBUG(3, "RASTER_resample: done");
+       POSTGIS_RT_DEBUG(3, "RASTER_GDALWarp: done");
 
        SET_VARSIZE(pgrast, pgrast->size);
        PG_RETURN_POINTER(pgrast);
index eff242d8c66e9667a3b87b7ad918ac63d32c1f36..c872d1c359bfecc63f3d05705ce2e3d9498b45c8 100644 (file)
@@ -1971,10 +1971,12 @@ CREATE OR REPLACE FUNCTION st_asraster(
        LANGUAGE 'sql' STABLE;
 
 -----------------------------------------------------------------------
--- ST_Resample
+-- ST_GDALWarp
+-- has no public functions
 -----------------------------------------------------------------------
+
 -- cannot be strict as almost all parameters can be NULL
-CREATE OR REPLACE FUNCTION _st_resample(
+CREATE OR REPLACE FUNCTION _st_gdalwarp(
        rast raster,
        algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125,
        srid integer DEFAULT NULL,
@@ -1984,9 +1986,13 @@ CREATE OR REPLACE FUNCTION _st_resample(
        width integer DEFAULT NULL, height integer DEFAULT NULL
 )
        RETURNS raster
-       AS 'MODULE_PATHNAME', 'RASTER_resample'
+       AS 'MODULE_PATHNAME', 'RASTER_GDALWarp'
        LANGUAGE 'c' STABLE;
 
+-----------------------------------------------------------------------
+-- ST_Resample
+-----------------------------------------------------------------------
+
 CREATE OR REPLACE FUNCTION st_resample(
        rast raster,
        srid integer DEFAULT NULL,
@@ -1996,7 +2002,7 @@ CREATE OR REPLACE FUNCTION st_resample(
        algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
 )
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $9,       $10, $2, $3, $4, $5, $6, $7, $8) $$
+       AS $$ SELECT _st_gdalwarp($1, $9,       $10, $2, $3, $4, $5, $6, $7, $8) $$
        LANGUAGE 'sql' STABLE;
 
 CREATE OR REPLACE FUNCTION st_resample(
@@ -2008,7 +2014,7 @@ CREATE OR REPLACE FUNCTION st_resample(
        algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
 )
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $9,       $10, $4, NULL, NULL, $5, $6, $7, $8, $2, $3) $$
+       AS $$ SELECT _st_gdalwarp($1, $9,       $10, $4, NULL, NULL, $5, $6, $7, $8, $2, $3) $$
        LANGUAGE 'sql' STABLE;
 
 CREATE OR REPLACE FUNCTION st_resample(
@@ -2041,7 +2047,7 @@ CREATE OR REPLACE FUNCTION st_resample(
                        scale_y := NULL;
                END IF;
 
-               RETURN _st_resample($1, $3, $4, sr_id, scale_x, scale_y, grid_x, grid_y, skew_x, skew_y, dim_x, dim_y);
+               RETURN _st_gdalwarp($1, $3, $4, sr_id, scale_x, scale_y, grid_x, grid_y, skew_x, skew_y, dim_x, dim_y);
        END;
        $$ LANGUAGE 'plpgsql' STABLE STRICT;
 
@@ -2061,17 +2067,17 @@ CREATE OR REPLACE FUNCTION st_resample(
 -----------------------------------------------------------------------
 CREATE OR REPLACE FUNCTION st_transform(rast raster, srid integer, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125, scalex double precision DEFAULT 0, scaley double precision DEFAULT 0)
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $3, $4, $2, $5, $6) $$
+       AS $$ SELECT _st_gdalwarp($1, $3, $4, $2, $5, $6) $$
        LANGUAGE 'sql' STABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_transform(rast raster, srid integer, scalex double precision, scaley double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $5, $6, $2, $3, $4) $$
+       AS $$ SELECT _st_gdalwarp($1, $5, $6, $2, $3, $4) $$
        LANGUAGE 'sql' STABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_transform(rast raster, srid integer, scalexy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $4, $5, $2, $3, $3) $$
+       AS $$ SELECT _st_gdalwarp($1, $4, $5, $2, $3, $3) $$
        LANGUAGE 'sql' STABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_transform(
@@ -2088,12 +2094,12 @@ CREATE OR REPLACE FUNCTION st_transform(
 -----------------------------------------------------------------------
 CREATE OR REPLACE FUNCTION st_rescale(rast raster, scalex double precision, scaley double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $4, $5, NULL, $2, $3) $$
+       AS $$ SELECT _st_gdalwarp($1, $4, $5, NULL, $2, $3) $$
        LANGUAGE 'sql' STABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_rescale(rast raster, scalexy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $3, $4, NULL, $2, $2) $$
+       AS $$ SELECT _st_gdalwarp($1, $3, $4, NULL, $2, $2) $$
        LANGUAGE 'sql' STABLE STRICT;
 
 -----------------------------------------------------------------------
@@ -2101,12 +2107,12 @@ CREATE OR REPLACE FUNCTION st_rescale(rast raster, scalexy double precision, alg
 -----------------------------------------------------------------------
 CREATE OR REPLACE FUNCTION st_reskew(rast raster, skewx double precision, skewy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $4, $5, NULL, 0, 0, NULL, NULL, $2, $3) $$
+       AS $$ SELECT _st_gdalwarp($1, $4, $5, NULL, 0, 0, NULL, NULL, $2, $3) $$
        LANGUAGE 'sql' STABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_reskew(rast raster, skewxy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $3, $4, NULL, 0, 0, NULL, NULL, $2, $2) $$
+       AS $$ SELECT _st_gdalwarp($1, $3, $4, NULL, 0, 0, NULL, NULL, $2, $2) $$
        LANGUAGE 'sql' STABLE STRICT;
 
 -----------------------------------------------------------------------
@@ -2119,7 +2125,7 @@ CREATE OR REPLACE FUNCTION st_snaptogrid(
        scalex double precision DEFAULT 0, scaley double precision DEFAULT 0
 )
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $4, $5, NULL, $6, $7, $2, $3) $$
+       AS $$ SELECT _st_gdalwarp($1, $4, $5, NULL, $6, $7, $2, $3) $$
        LANGUAGE 'sql' STABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_snaptogrid(
@@ -2129,7 +2135,7 @@ CREATE OR REPLACE FUNCTION st_snaptogrid(
        algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
 )
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $6, $7, NULL, $4, $5, $2, $3) $$
+       AS $$ SELECT _st_gdalwarp($1, $6, $7, NULL, $4, $5, $2, $3) $$
        LANGUAGE 'sql' STABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_snaptogrid(
@@ -2139,7 +2145,7 @@ CREATE OR REPLACE FUNCTION st_snaptogrid(
        algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
 )
        RETURNS raster
-       AS $$ SELECT _st_resample($1, $5, $6, NULL, $4, $4, $2, $3) $$
+       AS $$ SELECT _st_gdalwarp($1, $5, $6, NULL, $4, $4, $2, $3) $$
        LANGUAGE 'sql' STABLE STRICT;
 
 -----------------------------------------------------------------------
index 9facaa34e5f17d18ca86b4d7f2bcc262582624c8..ec2e2f7244ea231301d5a29f28d78aa9fe897643 100644 (file)
@@ -467,3 +467,6 @@ DROP FUNCTION IF EXISTS st_raster2worldcoordx(raster, int, int);
 DROP FUNCTION IF EXISTS st_raster2worldcoordx(raster, int);
 DROP FUNCTION IF EXISTS st_raster2worldcoordy(raster, int, int);
 DROP FUNCTION IF EXISTS st_raster2worldcoordy(raster, int);
+
+-- function name change
+DROP FUNCTION IF EXISTS _st_resample(raster, text, double precision, integer, double precision, double precision, double precision, double precision, double precision, double precision, integer, integer);