From: Bborie Park Date: Wed, 13 Jul 2011 19:33:12 +0000 (+0000) Subject: Complete refactoring of code from ST_Transform to ST_Resample. There are four new... X-Git-Tag: 2.0.0alpha1~1209 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ad776d498f6a832299490a82fd0817707b25a83;p=postgis Complete refactoring of code from ST_Transform to ST_Resample. There are four new functions as of this revision: ST_Resample, ST_Rescale, ST_Reskew and ST_SnapToGrid. ST_Transform is still present but points to ST_Resample. Associated ticket #1114 git-svn-id: http://svn.osgeo.org/postgis/trunk@7633 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_core/rt_api.c b/raster/rt_core/rt_api.c index cd40e00b9..a9471b306 100644 --- a/raster/rt_core/rt_api.c +++ b/raster/rt_core/rt_api.c @@ -5901,8 +5901,10 @@ rt_raster_from_gdal_dataset(GDALDatasetH ds) { * @param dst_srs : the warped raster's coordinate system * @param scale_x : the pixel width of the warped raster * @param scale_y : the pixel height of the warped raster - * @param ul_x : the X value of upper left corner of the warped raster - * @param ul_y : the Y value of upper left corner of the warped raster + * @param ul_xw : the X value of upper-left corner of the warped raster + * @param ul_yw : the Y value of upper-left corner of the warped raster + * @param grid_xw : the X value of point on a grid to align warped raster to + * @param grid_yw : the Y value of point on a grid to align warped raster to * @param skew_x : the X skew of the warped raster * @param skew_y : the Y skew of the warped raster * @param resample_alg : the resampling algorithm @@ -5915,7 +5917,8 @@ rt_raster rt_raster_gdal_warp( rt_raster raster, const char *src_srs, const char *dst_srs, double *scale_x, double *scale_y, - double *ul_x, double *ul_y, + double *ul_xw, double *ul_yw, + double *grid_xw, double *grid_yw, double *skew_x, double *skew_y, GDALResampleAlg resample_alg, double max_err ) { @@ -5952,6 +5955,12 @@ rt_raster rt_raster_gdal_warp( double pix_x = 0; double pix_y = 0; + double djunk = 0; + double grid_shift_xw = 0; + double grid_shift_yw = 0; + double grid_pix_x = 0; + double grid_pix_y = 0; + rt_raster rast = NULL; int i = 0; int j = 0; @@ -6085,38 +6094,147 @@ rt_raster rt_raster_gdal_warp( /* user-defined upper-left corner */ if ( - (NULL != ul_x) && - (FLT_NEQ(*ul_x, 0.0)) + NULL != ul_xw && + NULL != ul_yw ) { - min_x = *ul_x; + min_x = *ul_xw; + max_y = *ul_yw; ul_user = 1; } - if ( - (NULL != ul_y) && - (FLT_NEQ(*ul_y, 0.0)) + else if ( + ((NULL != ul_xw) && (NULL == ul_yw)) || + ((NULL == ul_xw) && (NULL != ul_yw)) ) { - max_y = *ul_y; - ul_user = 1; + rterror("rt_raster_gdal_warp: Both X and Y coordinate values must be provided for upper-left corner\n"); + + GDALClose(src_ds); + + for (i = 0; i < transform_opts_len; i++) rtdealloc(transform_opts[j]); + rtdealloc(transform_opts); + + GDALDeregisterDriver(src_drv); + GDALDestroyDriver(src_drv); + + return NULL; } /* skew */ - if (NULL != skew_x && NULL != skew_y) { + if (NULL != skew_x) dst_gt[2] = *skew_x; + if (NULL != skew_y) dst_gt[4] = *skew_y; - } /* user-defined scale */ if ( (NULL != scale_x) && - (FLT_NEQ(*scale_x, 0.0)) + (FLT_NEQ(*scale_x, 0.0)) && + (NULL != scale_y) && + (FLT_NEQ(*scale_y, 0.0)) ) { pix_x = fabs(*scale_x); + pix_y = fabs(*scale_y); } + else if ( + ((NULL != scale_x) && (NULL == scale_y)) || + ((NULL == scale_x) && (NULL != scale_y)) + ) { + rterror("rt_raster_gdal_warp: Both X and Y axis values must be provided for scale\n"); + + GDALClose(src_ds); + + for (i = 0; i < transform_opts_len; i++) rtdealloc(transform_opts[j]); + rtdealloc(transform_opts); + + GDALDeregisterDriver(src_drv); + GDALDestroyDriver(src_drv); + + return NULL; + } + + /* alignment only considered if upper-left corner not provided */ if ( - (NULL != scale_y) && - (FLT_NEQ(*scale_y, 0.0)) + !ul_user && ( + (NULL != grid_xw) || (NULL != grid_yw) + ) ) { - pix_y = fabs(*scale_y); + if ( + ((NULL != grid_xw) && (NULL == grid_yw)) || + ((NULL == grid_xw) && (NULL != grid_yw)) + ) { + rterror("rt_raster_gdal_warp: Both X and Y coordinate values must be provided for alignment\n"); + + GDALClose(src_ds); + + for (i = 0; i < transform_opts_len; i++) rtdealloc(transform_opts[j]); + rtdealloc(transform_opts); + + GDALDeregisterDriver(src_drv); + GDALDestroyDriver(src_drv); + + return NULL; + } + + /* use scale for alignment */ + if (FLT_NEQ(pix_x, 0.)) + grid_pix_x = pix_x; + else + grid_pix_x = fabs(dst_gt[1]); + if (FLT_NEQ(pix_y, 0.)) + grid_pix_y = pix_y; + else + grid_pix_y = fabs(dst_gt[5]); + + /* grid shift of upper left to match alignment grid */ + grid_shift_xw = grid_pix_x * modf(fabs(*grid_xw - dst_gt[0]) / grid_pix_x, &djunk); + grid_shift_yw = grid_pix_y * modf(fabs(*grid_yw - dst_gt[3]) / grid_pix_y, &djunk); + + /* shift along X axis for upper left */ + if (FLT_NEQ(grid_shift_xw, 0.)) { + min_x = dst_gt[0] + grid_shift_xw; + min_x = modf(fabs(*grid_xw - min_x) / grid_pix_x, &djunk); + if (FLT_NEQ(min_x, 0.)) grid_shift_xw *= -1; + min_x = dst_gt[0] + grid_shift_xw; + if (min_x > dst_gt[0]) { + grid_shift_xw = grid_pix_x - fabs(grid_shift_xw); + min_x = dst_gt[0] - grid_shift_xw; + } + + ul_user = 1; + } + else + min_x = dst_gt[0]; + + /* shift along Y axis for upper left */ + if (FLT_NEQ(grid_shift_yw, 0.)) { + max_y = dst_gt[3] + grid_shift_yw; + max_y = modf(fabs(*grid_yw - max_y) / grid_pix_y, &djunk); + if (FLT_NEQ(max_y, 0.)) grid_shift_yw *= -1; + max_y = dst_gt[3] + grid_shift_yw; + if (max_y < dst_gt[3]) { + grid_shift_yw = grid_pix_y - fabs(grid_shift_yw); + max_y = dst_gt[3] + grid_shift_yw; + } + + ul_user = 1; + } + else + max_y = dst_gt[3]; + + /* adjust width and height to account new upper left */ + if (ul_user) { + /* use suggested lower right corner */ + max_x = dst_gt[0] + dst_gt[1] * width; + min_y = dst_gt[3] + dst_gt[5] * height; + + width = (int) ceil((max_x - min_x + (grid_pix_x / 2.)) / grid_pix_x); + height = (int) ceil((max_y - min_y + (grid_pix_y / 2.)) / grid_pix_y); + dst_gt[1] = grid_pix_x; + dst_gt[5] = -1 * grid_pix_y; + RASTER_DEBUGF(3, "new dimensions: %d x %d", width, height); + } + + RASTER_DEBUGF(3, "shift is: %f, %f", grid_shift_xw, grid_shift_yw); + RASTER_DEBUGF(3, "new ul is: %f, %f", min_x, max_y); } /* process user-defined scale */ diff --git a/raster/rt_core/rt_api.h b/raster/rt_core/rt_api.h index 94d41ee6e..e69cbd7aa 100644 --- a/raster/rt_core/rt_api.h +++ b/raster/rt_core/rt_api.h @@ -934,8 +934,10 @@ rt_raster rt_raster_from_gdal_dataset(GDALDatasetH ds); * @param dst_srs : the warped raster's coordinate system * @param scale_x : the pixel width of the warped raster * @param scale_y : the pixel height of the warped raster - * @param ul_x : the X value of upper left corner of the warped raster - * @param ul_y : the Y value of upper left corner of the warped raster + * @param ul_xw : the X value of upper-left corner of the warped raster + * @param ul_yw : the Y value of upper-left corner of the warped raster + * @param grid_xw : the X value of point on a grid to align warped raster to + * @param grid_yw : the Y value of point on a grid to align warped raster to * @param skew_x : the X skew of the warped raster * @param skew_y : the Y skew of the warped raster * @param resample_alg : the resampling algorithm @@ -947,7 +949,8 @@ rt_raster rt_raster_from_gdal_dataset(GDALDatasetH ds); rt_raster rt_raster_gdal_warp(rt_raster raster, const char *src_srs, const char *dst_srs, double *scale_x, double *scale_y, - double *ul_x, double *ul_y, + double *ul_xw, double *ul_yw, + double *grid_xw, double *grid_yw, double *skew_x, double *skew_y, GDALResampleAlg resample_alg, double max_err); diff --git a/raster/rt_pg/rt_pg.c b/raster/rt_pg/rt_pg.c index d18c2e543..8ce4a74ef 100644 --- a/raster/rt_pg/rt_pg.c +++ b/raster/rt_pg/rt_pg.c @@ -4904,6 +4904,14 @@ Datum RASTER_resample(PG_FUNCTION_ARGS) double *scale_x = NULL; double *scale_y = NULL; + double gridw[2] = {0}; + double *grid_xw = NULL; + double *grid_yw = NULL; + + double skew[2] = {0}; + double *skew_x = NULL; + double *skew_y = NULL; + POSTGIS_RT_DEBUG(3, "RASTER_resample: Starting"); /* pgraster is null, return null */ @@ -4949,7 +4957,78 @@ Datum RASTER_resample(PG_FUNCTION_ARGS) rt_raster_destroy(raster); PG_RETURN_NULL(); } - POSTGIS_RT_DEBUGF(4, "destination srid: %d", dst_srid); + } + else + dst_srid = src_srid; + POSTGIS_RT_DEBUGF(4, "destination srid: %d", dst_srid); + + /* scale x */ + if (!PG_ARGISNULL(4)) { + scale[0] = PG_GETARG_FLOAT8(4); + if (FLT_NEQ(scale[0], 0)) scale_x = &scale[0]; + } + + /* scale y */ + if (!PG_ARGISNULL(5)) { + scale[1] = PG_GETARG_FLOAT8(5); + if (FLT_NEQ(scale[1], 0)) scale_y = &scale[1]; + } + + /* grid alignment x */ + if (!PG_ARGISNULL(6)) { + gridw[0] = PG_GETARG_FLOAT8(6); + grid_xw = &gridw[0]; + } + + /* grid alignment y */ + if (!PG_ARGISNULL(7)) { + gridw[1] = PG_GETARG_FLOAT8(7); + grid_yw = &gridw[1]; + } + + /* skew x */ + if (!PG_ARGISNULL(8)) { + skew[0] = PG_GETARG_FLOAT8(8); + if (FLT_NEQ(skew[0], 0)) skew_x = &skew[0]; + } + + /* skew y */ + if (!PG_ARGISNULL(9)) { + skew[1] = PG_GETARG_FLOAT8(9); + if (FLT_NEQ(skew[1], 0)) skew_y = &skew[1]; + } + + /* check that at least something is to be done */ + if ( + (dst_srid == SRID_UNKNOWN) && + (scale_x == NULL) && + (scale_y == NULL) && + (grid_xw == NULL) && + (grid_yw == NULL) && + (skew_x == NULL) && + (skew_y == NULL) + ) { + elog(NOTICE, "No resampling parameters provided. Returning original raster"); + rt_raster_destroy(raster); + PG_RETURN_POINTER(pgraster); + } + /* both values of alignment must be provided if any one is provided */ + else if ( + (grid_xw != NULL && grid_yw == NULL) || + (grid_xw == NULL && grid_yw != NULL) + ) { + elog(NOTICE, "Values must be provided for both X and Y coordinates when specifying the alignment. Returning original raster"); + rt_raster_destroy(raster); + PG_RETURN_POINTER(pgraster); + } + /* both values of scale must be provided if any one is provided */ + else if ( + (scale_x != NULL && scale_y == NULL) || + (scale_x == NULL && scale_y != NULL) + ) { + elog(NOTICE, "Values must be provided for both X and Y axis when specifying the scale. Returning original raster"); + rt_raster_destroy(raster); + PG_RETURN_POINTER(pgraster); } /* get srses from srids */ @@ -4974,23 +5053,12 @@ Datum RASTER_resample(PG_FUNCTION_ARGS) POSTGIS_RT_DEBUGF(4, "dst srs: %s", dst_srs); } - /* scale x */ - if (!PG_ARGISNULL(4)) { - scale[0] = PG_GETARG_FLOAT8(4); - scale_x = &scale[0]; - } - - /* scale y */ - if (!PG_ARGISNULL(5)) { - scale[1] = PG_GETARG_FLOAT8(5); - scale_y = &scale[1]; - } - rast = rt_raster_gdal_warp(raster, src_srs, dst_srs, scale_x, scale_y, NULL, NULL, - NULL, NULL, + grid_xw, grid_yw, + skew_x, skew_y, alg, max_err); rt_raster_destroy(raster); if (NULL != src_srs) pfree(src_srs); diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index 8e8f9b4b9..e01a4d1b1 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -1428,19 +1428,53 @@ CREATE OR REPLACE FUNCTION st_aspng(rast raster, nband int, compression int) ----------------------------------------------------------------------- -- ST_Resample ----------------------------------------------------------------------- +-- cannot be strict as almost all parameters can be NULL CREATE OR REPLACE FUNCTION _st_resample( rast raster, - algorithm text DEFAULT 'NearestNeighbour', - maxerr double precision DEFAULT 0.125, + algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125, srid integer DEFAULT NULL, scalex double precision DEFAULT 0, scaley double precision DEFAULT 0, - upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL, - skewx double precision DEFAULT NULL, skewy double precision DEFAULT NULL + gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL, + skewx double precision DEFAULT 0, skewy double precision DEFAULT 0 ) RETURNS raster AS 'MODULE_PATHNAME', 'RASTER_resample' LANGUAGE 'C' IMMUTABLE; +CREATE OR REPLACE FUNCTION st_resample( + rast raster, + srid integer DEFAULT NULL, + scalex double precision DEFAULT 0, scaley double precision DEFAULT 0, + gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL, + skewx double precision DEFAULT 0, skewy double precision DEFAULT 0, + 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) $$ + LANGUAGE 'sql' IMMUTABLE; + +CREATE OR REPLACE FUNCTION st_resample( + rast raster, + ref raster, + algorithm text DEFAULT 'NearestNeighbour', + maxerr double precision DEFAULT 0.125 +) + RETURNS raster + AS $$ + DECLARE + sr_id 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; + BEGIN + SELECT srid, scalex, scaley, upperleftx, upperlefty, skewx, skewy INTO sr_id, scale_x, scale_y, grid_x, grid_y, skew_x, skew_y FROM st_metadata($2); + RETURN _st_resample($1, $3, $4, sr_id, scale_x, scale_y, grid_x, grid_y, skew_x, skew_y); + END; + $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT; + ----------------------------------------------------------------------- -- ST_Transform ----------------------------------------------------------------------- @@ -1459,6 +1493,50 @@ CREATE OR REPLACE FUNCTION st_transform(rast raster, srid integer, scalexy doubl AS $$ SELECT _st_resample($1, $4, $5, $2, $3, $3) $$ LANGUAGE 'sql' IMMUTABLE STRICT; +----------------------------------------------------------------------- +-- ST_Rescale +----------------------------------------------------------------------- +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) $$ + LANGUAGE 'sql' IMMUTABLE 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) $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + +----------------------------------------------------------------------- +-- ST_Reskew +----------------------------------------------------------------------- +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) $$ + LANGUAGE 'sql' IMMUTABLE 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) $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + +----------------------------------------------------------------------- +-- ST_SnapToGrid +----------------------------------------------------------------------- +CREATE OR REPLACE FUNCTION st_snaptogrid(rast raster, gridx double precision, gridy double precision, 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, $4, $5, NULL, $6, $7, $2, $3) $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION st_snaptogrid(rast raster, gridx double precision, gridy double precision, scalex double precision, scaley double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125) + RETURNS raster + AS $$ SELECT _st_resample($1, $6, $7, NULL, $4, $5, $2, $3) $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION st_snaptogrid(rast raster, gridx double precision, gridy double precision, scalexy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125) + RETURNS raster + AS $$ SELECT _st_resample($1, $5, $6, NULL, $4, $4, $2, $3) $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + ----------------------------------------------------------------------- -- MapAlgebra ----------------------------------------------------------------------- diff --git a/raster/test/core/testapi.c b/raster/test/core/testapi.c index a0a593a38..183de483c 100644 --- a/raster/test/core/testapi.c +++ b/raster/test/core/testapi.c @@ -1311,7 +1311,7 @@ static void testRasterToGDAL() { rt_band_set_nodata(band, 0); rt_raster_set_offsets(raster, -500000, 600000); - rt_raster_set_scale(raster, 1000, 1000); + rt_raster_set_scale(raster, 1000, -1000); for (x = 0; x < xmax; x++) { for (y = 0; y < ymax; y++) { @@ -1481,7 +1481,7 @@ static void testGDALWarp() { rt_band_set_nodata(band, 0); rt_raster_set_offsets(raster, -500000, 600000); - rt_raster_set_scale(raster, 1000, 1000); + rt_raster_set_scale(raster, 1000, -1000); for (x = 0; x < xmax; x++) { for (y = 0; y < ymax; y++) { @@ -1496,11 +1496,12 @@ static void testGDALWarp() { NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, GRA_NearestNeighbour, -1 ); CHECK(rast); - CHECK((rt_raster_get_width(rast) == 124)); - CHECK((rt_raster_get_height(rast) == 117)); + CHECK((rt_raster_get_width(rast) == 122)); + CHECK((rt_raster_get_height(rast) == 116)); CHECK((rt_raster_get_num_bands(rast) != 0)); band = rt_raster_get_band(rast, 0); diff --git a/raster/test/regress/Makefile.in b/raster/test/regress/Makefile.in index 998d99766..848112863 100644 --- a/raster/test/regress/Makefile.in +++ b/raster/test/regress/Makefile.in @@ -87,7 +87,7 @@ TEST_UTILITY = \ create_rt_mapalgebra_test.sql \ rt_mapalgebra.sql \ rt_reclass.sql \ - rt_transform.sql \ + rt_resample.sql \ $(NULL) TEST_GIST = \ diff --git a/raster/test/regress/rt_resample.sql b/raster/test/regress/rt_resample.sql new file mode 100644 index 000000000..c2cd6aa9a --- /dev/null +++ b/raster/test/regress/rt_resample.sql @@ -0,0 +1,546 @@ +DROP TABLE IF EXISTS raster_resample_src; +DROP TABLE IF EXISTS raster_resample_dst; +CREATE TABLE raster_resample_src ( + rast raster +); +CREATE TABLE raster_resample_dst ( + rid varchar, + rast raster +); +CREATE OR REPLACE FUNCTION make_test_raster() + RETURNS void + AS $$ + DECLARE + width int := 10; + height int := 10; + x int; + y int; + rast raster; + BEGIN + rast := ST_MakeEmptyRaster(width, height, -500000, 600000, 1000, -1000, 0, 0, 1002163); + rast := ST_AddBand(rast, 1, '64BF', 0, 0); + + FOR x IN 1..width LOOP + FOR y IN 1..height LOOP + rast := ST_SetValue(rast, 1, x, y, ((x::double precision * y) + (x + y) + (x + y * x)) / (x + y + 1)); + END LOOP; + END LOOP; + + INSERT INTO raster_resample_src VALUES (rast); + + RETURN; + END; + $$ LANGUAGE 'plpgsql'; +SELECT make_test_raster(); +DELETE FROM "spatial_ref_sys" WHERE srid = 1002163; +DELETE FROM "spatial_ref_sys" WHERE srid = 1003309; +DELETE FROM "spatial_ref_sys" WHERE srid = 1003310; +DELETE FROM "spatial_ref_sys" WHERE srid = 1004269; +INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (1002163,'EPSG',2163,'PROJCS["unnamed",GEOGCS["unnamed ellipse",DATUM["unknown",SPHEROID["unnamed",6370997,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["latitude_of_center",45],PARAMETER["longitude_of_center",-100],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1],AUTHORITY["EPSG","2163"]]','+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs '); +INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (1003309,'EPSG',3309,'PROJCS["NAD27 / California Albers",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.9786982139006,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["standard_parallel_1",34],PARAMETER["standard_parallel_2",40.5],PARAMETER["latitude_of_center",0],PARAMETER["longitude_of_center",-120],PARAMETER["false_easting",0],PARAMETER["false_northing",-4000000],AUTHORITY["EPSG","3309"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=clrk66 +datum=NAD27 +units=m +no_defs '); +INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (1003310,'EPSG',3310,'PROJCS["NAD83 / California Albers",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["standard_parallel_1",34],PARAMETER["standard_parallel_2",40.5],PARAMETER["latitude_of_center",0],PARAMETER["longitude_of_center",-120],PARAMETER["false_easting",0],PARAMETER["false_northing",-4000000],AUTHORITY["EPSG","3310"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs '); +INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (1004269,'EPSG',4269,'GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]]','+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs '); + +-- ST_Resample +INSERT INTO raster_resample_dst (rid, rast) VALUES ( + 1.1, (SELECT ST_Resample( + rast + ) FROM raster_resample_src) +), ( + 1.2, (SELECT ST_Resample( + rast, + 1003310 + ) FROM raster_resample_src) +), ( + 1.3, (SELECT ST_Resample( + rast, + 1003309 + ) FROM raster_resample_src) +), ( + 1.4, (SELECT ST_Resample( + rast, + 1004269 + ) FROM raster_resample_src) +), ( + 1.5, (SELECT ST_Resample( + rast, + 1003310, + 500, 500, + NULL, NULL, + 0, 0, + 'NearestNeighbor', 0.125 + ) FROM raster_resample_src) +), ( + 1.6, (SELECT ST_Resample( + rast, + NULL, + 100, NULL + ) FROM raster_resample_src) +), ( + 1.7, (SELECT ST_Resample( + rast, + NULL, + NULL::double precision, 100 + ) FROM raster_resample_src) +), ( + 1.8, (SELECT ST_Resample( + rast, + NULL, + 500, 500 + ) FROM raster_resample_src) +), ( + 1.9, (SELECT ST_Resample( + rast, + NULL, + 250, 250, + NULL, NULL, + NULL, NULL + ) FROM raster_resample_src) +), ( + 1.10, (SELECT ST_Resample( + rast, + NULL, + 250, 250, + NULL, NULL, + NULL, NULL, + 'Bilinear', 0 + ) FROM raster_resample_src) +), ( + 1.11, (SELECT ST_Resample( + rast, + NULL, + NULL, NULL, + -500000, 600000 + ) FROM raster_resample_src) +), ( + 1.12, (SELECT ST_Resample( + rast, + NULL, + NULL, NULL, + -500001, 600000 + ) FROM raster_resample_src) +), ( + 1.13, (SELECT ST_Resample( + rast, + NULL, + NULL, NULL, + -500000, 600009 + ) FROM raster_resample_src) +), ( + 1.14, (SELECT ST_Resample( + rast, + NULL, + NULL, NULL, + -500100, 599950 + ) FROM raster_resample_src) +), ( + 1.15, (SELECT ST_Resample( + rast, + NULL, + 50, 50, + -290, 7 + ) FROM raster_resample_src) +), ( + 1.16, (SELECT ST_Resample( + rast, + NULL, + 121, 121, + 0, 0 + ) FROM raster_resample_src) +), ( + 1.17, (SELECT ST_Resample( + rast, + 1003310, + 50, 50, + -290, 7 + ) FROM raster_resample_src) +), ( + 1.18, (SELECT ST_Resample( + rast, + 1003309, + 50, 50, + -290, 7 + ) FROM raster_resample_src) +), ( + 1.19, (SELECT ST_Resample( + rast, + NULL, + NULL, NULL, + NULL, NULL, + 3, 3 + ) FROM raster_resample_src) +), ( + 1.20, (SELECT ST_Resample( + rast, + 1003310, + NULL, NULL, + NULL, NULL, + 3, 3, + 'Cubic', 0 + ) FROM raster_resample_src) +), ( + 1.21, (SELECT ST_Resample( + rast, + 1003309, + NULL, NULL, + NULL, NULL, + 1, 3, + 'Bilinear' + ) FROM raster_resample_src) +), ( + 1.22, (SELECT ST_Resample( + rast, + 1003310, + 500, 500, + NULL, NULL, + 3, 3, + 'Cubic', 0 + ) FROM raster_resample_src) +), ( + 1.23, (SELECT ST_Resample( + rast, + 1003310, + 500, 500, + -12048, 14682, + 0, 6, + 'CubicSpline' + ) FROM raster_resample_src) +), ( + 1.24, (SELECT ST_Resample( + rast, + ST_MakeEmptyRaster(5, 5, -654321, 123456, 50, -100, 3, 0, 1002163) + ) FROM raster_resample_src) +); + +-- ST_Transform +INSERT INTO raster_resample_dst (rid, rast) VALUES ( + 2.1, (SELECT ST_Transform( + rast, + 1003310 + ) FROM raster_resample_src) +), ( + 2.2, (SELECT ST_Transform( + rast, + 1003309 + ) FROM raster_resample_src) +), ( + 2.3, (SELECT ST_Transform( + rast, + 1004269 + ) FROM raster_resample_src) +), ( + 2.4, (SELECT ST_Transform( + rast, + 1003310, NULL + ) FROM raster_resample_src) +), ( + 2.5, (SELECT ST_Transform( + rast, + 1003310, 'Bilinear' + ) FROM raster_resample_src) +), ( + 2.6, (SELECT ST_Transform( + rast, + 1003310, 'Bilinear', NULL::double precision + ) FROM raster_resample_src) +), ( + 2.7, (SELECT ST_Transform( + rast, + 1003310, 'Cubic', 0.0 + ) FROM raster_resample_src) +), ( + 2.8, (SELECT ST_Transform( + rast, + 1003310, 'NearestNeighbour', 0.0 + ) FROM raster_resample_src) +), ( + 2.9, (SELECT ST_Transform( + rast, + 1003310, 'NearestNeighbor', 0.0 + ) FROM raster_resample_src) +), ( + 2.10, (SELECT ST_Transform( + rast, + 1003310, 'NearestNeighbor', 0.125, 500, 500 + ) FROM raster_resample_src) +), ( + 2.11, (SELECT ST_Transform( + rast, + 1003309, 'Cubic', 0., 100, 100 + ) FROM raster_resample_src) +), ( + 2.12, (SELECT ST_Transform( + rast, + 1003310, 'CubicSpline', 0., 2000, 2000 + ) FROM raster_resample_src) +), ( + 2.13, (SELECT ST_Transform( + rast, + 1003310, 'CubicSpline', 0.1, 1500, 1500 + ) FROM raster_resample_src) +), ( + 2.14, (SELECT ST_Transform( + rast, + 1003310, 500, 500 + ) FROM raster_resample_src) +), ( + 2.15, (SELECT ST_Transform( + rast, + 1003310, 750 + ) FROM raster_resample_src) +); + +-- ST_Rescale +INSERT INTO raster_resample_dst (rid, rast) VALUES ( + 3.1, (SELECT ST_Rescale( + rast, + 100, 100 + ) FROM raster_resample_src) +), ( + 3.2, (SELECT ST_Rescale( + rast, + 100 + ) FROM raster_resample_src) +), ( + 3.3, (SELECT ST_Rescale( + rast, + 0, 0 + ) FROM raster_resample_src) +), ( + 3.4, (SELECT ST_Rescale( + rast, + 0 + ) FROM raster_resample_src) +), ( + 3.5, (SELECT ST_Rescale( + rast, + 100, 100, + 'Bilinear', 0 + ) FROM raster_resample_src) +), ( + 3.6, (SELECT ST_Rescale( + rast, + 150, 125, + 'Cubic' + ) FROM raster_resample_src) +); + +-- ST_Reskew +INSERT INTO raster_resample_dst (rid, rast) VALUES ( + 4.1, (SELECT ST_Reskew( + rast, + 0, 0 + ) FROM raster_resample_src) +), ( + 4.2, (SELECT ST_Reskew( + rast, + 1, 1 + ) FROM raster_resample_src) +), ( + 4.3, (SELECT ST_Reskew( + rast, + 0.5, 0 + ) FROM raster_resample_src) +), ( + 4.4, (SELECT ST_Reskew( + rast, + 10 + ) FROM raster_resample_src) +), ( + 4.5, (SELECT ST_Reskew( + rast, + 10, + 'CubicSpline' + ) FROM raster_resample_src) +), ( + 4.6, (SELECT ST_Reskew( + rast, + 10, + 'Bilinear', 0 + ) FROM raster_resample_src) +); + +-- ST_SnapToGrid +INSERT INTO raster_resample_dst (rid, rast) VALUES ( + 5.1, (SELECT ST_SnapToGrid( + rast, + -500000, 600000 + ) FROM raster_resample_src) +), ( + 5.2, (SELECT ST_SnapToGrid( + rast, + 0, 0 + ) FROM raster_resample_src) +), ( + 5.3, (SELECT ST_SnapToGrid( + rast, + -1, 600000 + ) FROM raster_resample_src) +), ( + 5.4, (SELECT ST_SnapToGrid( + rast, + -500001, 600000 + ) FROM raster_resample_src) +), ( + 5.5, (SELECT ST_SnapToGrid( + rast, + 1, 600000 + ) FROM raster_resample_src) +), ( + 5.6, (SELECT ST_SnapToGrid( + rast, + -500000, -1 + ) FROM raster_resample_src) +), ( + 5.7, (SELECT ST_SnapToGrid( + rast, + -500000, -9 + ) FROM raster_resample_src) +), ( + 5.8, (SELECT ST_SnapToGrid( + rast, + -500000, 1 + ) FROM raster_resample_src) +), ( + 5.9, (SELECT ST_SnapToGrid( + rast, + -500000, 9 + ) FROM raster_resample_src) +), ( + 5.10, (SELECT ST_SnapToGrid( + rast, + -5, 1 + ) FROM raster_resample_src) +), ( + 5.11, (SELECT ST_SnapToGrid( + rast, + 9, -9 + ) FROM raster_resample_src) +), ( + 5.12, (SELECT ST_SnapToGrid( + rast, + -500000, 600000, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.13, (SELECT ST_SnapToGrid( + rast, + 0, 0, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.14, (SELECT ST_SnapToGrid( + rast, + -1, 600000, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.15, (SELECT ST_SnapToGrid( + rast, + -500001, 600000, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.16, (SELECT ST_SnapToGrid( + rast, + 1, 600000, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.17, (SELECT ST_SnapToGrid( + rast, + -500000, -1, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.18, (SELECT ST_SnapToGrid( + rast, + -500000, -9, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.19, (SELECT ST_SnapToGrid( + rast, + -500000, 1, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.20, (SELECT ST_SnapToGrid( + rast, + -500000, 9, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.21, (SELECT ST_SnapToGrid( + rast, + -5, 1, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.22, (SELECT ST_SnapToGrid( + rast, + 9, -9, + 50, 50 + ) FROM raster_resample_src) +), ( + 5.23, (SELECT ST_SnapToGrid( + rast, + 0, 0, + 121 + ) FROM raster_resample_src) +), ( + 5.24, (SELECT ST_SnapToGrid( + rast, + -500000, 1, + 121 + ) FROM raster_resample_src) +), ( + 5.25, (SELECT ST_SnapToGrid( + rast, + -500000, 9, + 121 + ) FROM raster_resample_src) +), ( + 5.26, (SELECT ST_SnapToGrid( + rast, + -5, 1, + 121 + ) FROM raster_resample_src) +), ( + 5.27, (SELECT ST_SnapToGrid( + rast, + 9, -9, + 121 + ) FROM raster_resample_src) +); + +SELECT + rid, + srid, + width, + height, + numbands, + round(scalex::numeric, 3) AS scalex, + round(scaley::numeric, 3) AS scaley, + round(skewx::numeric, 3) AS skewx, + round(skewy::numeric, 3) AS skewy, + round(upperleftx::numeric, 3) AS upperleftx, + round(upperlefty::numeric, 3) AS upperlefty, + count > 0, + round(min::numeric, 3) >= 1.667 AS min_check, + round(max::numeric, 3) <= 100.995 AS max_check +FROM ( + SELECT + rid, + (ST_MetaData(rast)).*, + (ST_SummaryStats(rast)).* + FROM raster_resample_dst + ORDER BY rid +) foo; +DELETE FROM "spatial_ref_sys" WHERE srid = 1002163; +DELETE FROM "spatial_ref_sys" WHERE srid = 1003309; +DELETE FROM "spatial_ref_sys" WHERE srid = 1003310; +DELETE FROM "spatial_ref_sys" WHERE srid = 1004269; +DROP TABLE raster_resample_src; +DROP TABLE raster_resample_dst; +DROP FUNCTION make_test_raster(); diff --git a/raster/test/regress/rt_resample_expected b/raster/test/regress/rt_resample_expected new file mode 100644 index 000000000..0cf634b2f --- /dev/null +++ b/raster/test/regress/rt_resample_expected @@ -0,0 +1,82 @@ +NOTICE: table "raster_resample_src" does not exist, skipping +NOTICE: table "raster_resample_dst" does not exist, skipping +NOTICE: Values must be provided for both X and Y axis when specifying the scale. Returning original raster +NOTICE: Values must be provided for both X and Y axis when specifying the scale. Returning original raster +1.1|1002163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t +1.10|1002163|40|40|1|250.000|-250.000|0.000|0.000|-500000.000|600000.000|t|t|t +1.11|1002163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t +1.12|1002163|11|11|1|1000.000|-1000.000|0.000|0.000|-500001.000|600000.000|t|t|t +1.13|1002163|11|11|1|1000.000|-1000.000|0.000|0.000|-500000.000|600009.000|t|t|t +1.14|1002163|11|12|1|1000.000|-1000.000|0.000|0.000|-500100.000|600950.000|t|t|t +1.15|1002163|201|201|1|50.000|-50.000|0.000|0.000|-500010.000|600007.000|t|t|t +1.16|1002163|84|84|1|121.000|-121.000|0.000|0.000|-500093.000|600039.000|t|t|t +1.17|1003310|244|244|1|50.000|-50.000|0.000|0.000|950710.000|1409307.000|t|t|t +1.18|1003309|243|244|1|50.000|-50.000|0.000|0.000|950760.000|1409107.000|t|t|t +1.19|1002163|10|10|1|1000.000|-1000.000|3.000|3.000|-500000.000|600000.000|t|t|t +1.2|1003310|12|12|1|1009.894|-1009.894|0.000|0.000|950732.188|1409281.783|t|t|t +1.20|1003310|12|12|1|1009.894|-1009.894|3.000|3.000|950732.188|1409281.783|t|t|t +1.21|1003309|12|12|1|1009.916|-1009.916|1.000|3.000|950762.305|1409088.896|t|t|t +1.22|1003310|24|24|1|500.000|-500.000|3.000|3.000|950732.188|1409281.783|t|t|t +1.23|1003310|26|26|1|500.000|-500.000|0.000|6.000|950452.000|1409682.000|t|t|t +1.24|1002163|201|102|1|50.000|-100.000|3.000|0.000|-500021.000|600056.000|t|t|t +1.3|1003309|12|12|1|1009.916|-1009.916|0.000|0.000|950762.305|1409088.896|t|t|t +1.4|1004269|12|8|1|0.012|-0.012|0.000|0.000|-107.029|50.206|t|t|t +1.5|1003310|24|24|1|500.000|-500.000|0.000|0.000|950732.188|1409281.783|t|t|t +1.6|1002163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t +1.7|1002163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t +1.8|1002163|20|20|1|500.000|-500.000|0.000|0.000|-500000.000|600000.000|t|t|t +1.9|1002163|40|40|1|250.000|-250.000|0.000|0.000|-500000.000|600000.000|t|t|t +2.1|1003310|12|12|1|1009.894|-1009.894|0.000|0.000|950732.188|1409281.783|t|t|t +2.10|1003310|24|24|1|500.000|-500.000|0.000|0.000|950732.188|1409281.783|t|t|t +2.11|1003309|121|121|1|100.000|-100.000|0.000|0.000|950762.305|1409088.896|t|t|t +2.12|1003310|6|6|1|2000.000|-2000.000|0.000|0.000|950732.188|1409281.783|t|t|t +2.13|1003310|8|8|1|1500.000|-1500.000|0.000|0.000|950732.188|1409281.783|t|t|t +2.14|1003310|24|24|1|500.000|-500.000|0.000|0.000|950732.188|1409281.783|t|t|t +2.15|1003310|16|16|1|750.000|-750.000|0.000|0.000|950732.188|1409281.783|t|t|t +2.2|1003309|12|12|1|1009.916|-1009.916|0.000|0.000|950762.305|1409088.896|t|t|t +2.3|1004269|12|8|1|0.012|-0.012|0.000|0.000|-107.029|50.206|t|t|t +2.4||||||||||||| +2.5|1003310|12|12|1|1009.894|-1009.894|0.000|0.000|950732.188|1409281.783|t|t|t +2.6||||||||||||| +2.7|1003310|12|12|1|1009.894|-1009.894|0.000|0.000|950732.188|1409281.783|t|t|t +2.8|1003310|12|12|1|1009.894|-1009.894|0.000|0.000|950732.188|1409281.783|t|t|t +2.9|1003310|12|12|1|1009.894|-1009.894|0.000|0.000|950732.188|1409281.783|t|t|t +3.1|1002163|100|100|1|100.000|-100.000|0.000|0.000|-500000.000|600000.000|t|t|t +3.2|1002163|100|100|1|100.000|-100.000|0.000|0.000|-500000.000|600000.000|t|t|t +3.3|1002163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t +3.4|1002163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t +3.5|1002163|100|100|1|100.000|-100.000|0.000|0.000|-500000.000|600000.000|t|t|t +3.6|1002163|67|80|1|150.000|-125.000|0.000|0.000|-500000.000|600000.000|t|t|t +4.1|1002163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t +4.2|1002163|10|10|1|1000.000|-1000.000|1.000|1.000|-500000.000|600000.000|t|t|t +4.3|1002163|10|10|1|1000.000|-1000.000|0.500|0.000|-500000.000|600000.000|t|t|t +4.4|1002163|10|10|1|1000.000|-1000.000|10.000|10.000|-500000.000|600000.000|t|t|t +4.5|1002163|10|10|1|1000.000|-1000.000|10.000|10.000|-500000.000|600000.000|t|t|t +4.6|1002163|10|10|1|1000.000|-1000.000|10.000|10.000|-500000.000|600000.000|t|t|t +5.1|1002163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t +5.10|1002163|11|11|1|1000.000|-1000.000|0.000|0.000|-500005.000|600001.000|t|t|t +5.11|1002163|12|12|1|1000.000|-1000.000|0.000|0.000|-500991.000|600991.000|t|t|t +5.12|1002163|200|200|1|50.000|-50.000|0.000|0.000|-500000.000|600000.000|t|t|t +5.13|1002163|200|200|1|50.000|-50.000|0.000|0.000|-500000.000|600000.000|t|t|t +5.14|1002163|201|201|1|50.000|-50.000|0.000|0.000|-500001.000|600000.000|t|t|t +5.15|1002163|201|201|1|50.000|-50.000|0.000|0.000|-500001.000|600000.000|t|t|t +5.16|1002163|202|201|1|50.000|-50.000|0.000|0.000|-500049.000|600000.000|t|t|t +5.17|1002163|201|202|1|50.000|-50.000|0.000|0.000|-500000.000|600049.000|t|t|t +5.18|1002163|201|202|1|50.000|-50.000|0.000|0.000|-500000.000|600041.000|t|t|t +5.19|1002163|201|201|1|50.000|-50.000|0.000|0.000|-500000.000|600001.000|t|t|t +5.2|1002163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t +5.20|1002163|201|201|1|50.000|-50.000|0.000|0.000|-500000.000|600009.000|t|t|t +5.21|1002163|201|201|1|50.000|-50.000|0.000|0.000|-500005.000|600001.000|t|t|t +5.22|1002163|202|202|1|50.000|-50.000|0.000|0.000|-500041.000|600041.000|t|t|t +5.23|1002163|84|84|1|121.000|-121.000|0.000|0.000|-500093.000|600039.000|t|t|t +5.24|1002163|84|84|1|121.000|-121.000|0.000|0.000|-500000.000|600040.000|t|t|t +5.25|1002163|84|84|1|121.000|-121.000|0.000|0.000|-500000.000|600048.000|t|t|t +5.26|1002163|84|84|1|121.000|-121.000|0.000|0.000|-500098.000|600040.000|t|t|t +5.27|1002163|84|84|1|121.000|-121.000|0.000|0.000|-500037.000|600030.000|t|t|t +5.3|1002163|11|11|1|1000.000|-1000.000|0.000|0.000|-500001.000|600000.000|t|t|t +5.4|1002163|11|11|1|1000.000|-1000.000|0.000|0.000|-500001.000|600000.000|t|t|t +5.5|1002163|12|11|1|1000.000|-1000.000|0.000|0.000|-500999.000|600000.000|t|t|t +5.6|1002163|11|12|1|1000.000|-1000.000|0.000|0.000|-500000.000|600999.000|t|t|t +5.7|1002163|11|12|1|1000.000|-1000.000|0.000|0.000|-500000.000|600991.000|t|t|t +5.8|1002163|11|11|1|1000.000|-1000.000|0.000|0.000|-500000.000|600001.000|t|t|t +5.9|1002163|11|11|1|1000.000|-1000.000|0.000|0.000|-500000.000|600009.000|t|t|t diff --git a/raster/test/regress/rt_transform.sql b/raster/test/regress/rt_transform.sql deleted file mode 100644 index 3c156d8a2..000000000 --- a/raster/test/regress/rt_transform.sql +++ /dev/null @@ -1,142 +0,0 @@ -CREATE TABLE raster_transform_src ( - rast raster -); -CREATE TABLE raster_transform_dst ( - rast raster -); -CREATE OR REPLACE FUNCTION make_test_raster() - RETURNS void - AS $$ - DECLARE - width int := 100; - height int := 100; - x int; - y int; - rast raster; - BEGIN - rast := ST_MakeEmptyRaster(width, height, -500000, 600000, 1000, 1000, 0, 0, 1002163); - rast := ST_AddBand(rast, 1, '64BF', 0, 0); - - FOR x IN 1..width LOOP - FOR y IN 1..height LOOP - rast := ST_SetValue(rast, 1, x, y, ((x::double precision * y) + (x + y) + (x + y * x)) / (x + y + 1)); - END LOOP; - END LOOP; - - INSERT INTO raster_transform_src VALUES (rast); - - RETURN; - END; - $$ LANGUAGE 'plpgsql'; -SELECT make_test_raster(); -DELETE FROM "spatial_ref_sys" WHERE srid = 1002163; -DELETE FROM "spatial_ref_sys" WHERE srid = 1003309; -DELETE FROM "spatial_ref_sys" WHERE srid = 1003310; -DELETE FROM "spatial_ref_sys" WHERE srid = 1004269; -INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (1002163,'EPSG',2163,'PROJCS["unnamed",GEOGCS["unnamed ellipse",DATUM["unknown",SPHEROID["unnamed",6370997,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["latitude_of_center",45],PARAMETER["longitude_of_center",-100],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1],AUTHORITY["EPSG","2163"]]','+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs '); -INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (1003309,'EPSG',3309,'PROJCS["NAD27 / California Albers",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.9786982139006,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["standard_parallel_1",34],PARAMETER["standard_parallel_2",40.5],PARAMETER["latitude_of_center",0],PARAMETER["longitude_of_center",-120],PARAMETER["false_easting",0],PARAMETER["false_northing",-4000000],AUTHORITY["EPSG","3309"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=clrk66 +datum=NAD27 +units=m +no_defs '); -INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (1003310,'EPSG',3310,'PROJCS["NAD83 / California Albers",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["standard_parallel_1",34],PARAMETER["standard_parallel_2",40.5],PARAMETER["latitude_of_center",0],PARAMETER["longitude_of_center",-120],PARAMETER["false_easting",0],PARAMETER["false_northing",-4000000],AUTHORITY["EPSG","3310"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs '); -INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (1004269,'EPSG',4269,'GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]]','+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs '); -INSERT INTO raster_transform_dst VALUES ( - (SELECT ST_Transform( - rast, - 1003310 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003309 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1004269 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, NULL - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, 'Bilinear' - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, 'Bilinear', NULL::double precision - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, 'Cubic', 0.0 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, 'NearestNeighbour', 0.0 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, 'NearestNeighbor', 0.0 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, 'NearestNeighbor', 0.125, 500, 500 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003309, 'Cubic', 0., 100, 100 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, 'CubicSpline', 0., 2000, 2000 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, 'Lanczos', 0.1, 1500, 1500 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, 500, 500 - ) FROM raster_transform_src) -), ( - (SELECT ST_Transform( - rast, - 1003310, 750 - ) FROM raster_transform_src) -); -SELECT - srid, - width, - height, - numbands, - round(scalex::numeric, 3), - round(scaley::numeric, 3), - round(skewx::numeric, 3), - round(skewy::numeric, 3), - round(upperleftx::numeric, 3), - round(upperlefty::numeric, 3), - count > 0, - round(min::numeric, 3) >= 1.667, - round(max::numeric, 3) <= 100.995 -FROM ( - SELECT - (ST_MetaData(rast)).*, - (ST_SummaryStats(rast)).* - FROM raster_transform_dst -) foo; -DELETE FROM "spatial_ref_sys" WHERE srid = 1002163; -DELETE FROM "spatial_ref_sys" WHERE srid = 1003309; -DELETE FROM "spatial_ref_sys" WHERE srid = 1003310; -DELETE FROM "spatial_ref_sys" WHERE srid = 1004269; -DROP TABLE raster_transform_src; -DROP TABLE raster_transform_dst; -DROP FUNCTION make_test_raster(); diff --git a/raster/test/regress/rt_transform_expected b/raster/test/regress/rt_transform_expected deleted file mode 100644 index a40155b41..000000000 --- a/raster/test/regress/rt_transform_expected +++ /dev/null @@ -1,15 +0,0 @@ -1003310|124|117|1|995.548|-995.548|0.000|0.000|928003.811|1523901.938|t|t|t -1003309|124|117|1|995.565|-995.565|0.000|0.000|928033.562|1523709.887|t|t|t -1004269|134|85|1|0.011|-0.011|0.000|0.000|-107.162|51.167|t|t|t -|||||||||||| -1003310|124|117|1|995.548|-995.548|0.000|0.000|928003.811|1523901.938|t|t|t -|||||||||||| -1003310|124|117|1|995.548|-995.548|0.000|0.000|928003.811|1523901.938|t|t|t -1003310|124|117|1|995.548|-995.548|0.000|0.000|928003.811|1523901.938|t|t|t -1003310|124|117|1|995.548|-995.548|0.000|0.000|928003.811|1523901.938|t|t|t -1003310|247|233|1|500.000|-500.000|0.000|0.000|928003.811|1523901.938|t|t|t -1003309|1235|1165|1|100.000|-100.000|0.000|0.000|928033.562|1523709.887|t|t|t -1003310|62|58|1|2000.000|-2000.000|0.000|0.000|928003.811|1523901.938|t|t|t -1003310|82|78|1|1500.000|-1500.000|0.000|0.000|928003.811|1523901.938|t|t|t -1003310|247|233|1|500.000|-500.000|0.000|0.000|928003.811|1523901.938|t|t|t -1003310|165|155|1|750.000|-750.000|0.000|0.000|928003.811|1523901.938|t|t|t