From ad0b84685abd60fa55b1436c2fc7e04f94a6cd68 Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Tue, 24 May 2011 14:27:08 +0000 Subject: [PATCH] - Added test testgdalraster.in which properly tests the output of ST_AsGDALRaster. This test makes use of rtgdalraster.py found in raster/scripts/python, which itself requires psycopg2. - Refactored rt_asgdalraster.sql, rt_astiff.sql, rt_asjpeg.sql and rt_aspng.sql to no longer attempt to validate the output of the respective functions with an MD5 checksum but rather be a test of the functions' behaviors. git-svn-id: http://svn.osgeo.org/postgis/trunk@7235 b70326c6-7e19-0410-871a-916f4a2858ee --- raster/test/regress/Makefile.in | 7 + raster/test/regress/rt_asgdalraster.sql | 318 +++++++++++-------- raster/test/regress/rt_asgdalraster_expected | 30 +- raster/test/regress/rt_asjpeg.sql | 166 ++++++---- raster/test/regress/rt_asjpeg_expected | 8 +- raster/test/regress/rt_aspng.sql | 194 ++++++----- raster/test/regress/rt_aspng_expected | 8 +- raster/test/regress/rt_astiff.sql | 150 +++++---- raster/test/regress/rt_astiff_expected | 12 +- raster/test/regress/testgdalraster.in | 164 ++++++++++ raster/test/regress/testgdalraster.test | 15 + raster/test/regress/testgdalraster_expected | 27 ++ 12 files changed, 734 insertions(+), 365 deletions(-) create mode 100644 raster/test/regress/testgdalraster.in create mode 100644 raster/test/regress/testgdalraster.test create mode 100644 raster/test/regress/testgdalraster_expected diff --git a/raster/test/regress/Makefile.in b/raster/test/regress/Makefile.in index d9ab152b2..c9de18d9d 100644 --- a/raster/test/regress/Makefile.in +++ b/raster/test/regress/Makefile.in @@ -141,3 +141,10 @@ check: rtpostgis.sql #clean: # $(RM) run_test +# $(RM) testgdalraster + +testgdalraster: testgdalraster.in Makefile + sed -e "s#@POSTGIS_SRC@#$(POSTGIS_SRC)#" $< > $@ + chmod +x $@ + chmod +x ../../scripts/python/rtgdalraster.py + ./testgdalraster diff --git a/raster/test/regress/rt_asgdalraster.sql b/raster/test/regress/rt_asgdalraster.sql index 46eef9d22..d2f5cdd60 100644 --- a/raster/test/regress/rt_asgdalraster.sql +++ b/raster/test/regress/rt_asgdalraster.sql @@ -1,147 +1,207 @@ -SELECT md5( - ST_AsGDALRaster( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '64BF', 123.4567, NULL), - 'GTiff' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand( +SELECT CASE + WHEN length( + ST_AsGDALRaster( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '64BF', 123.4567, NULL), + 'GTiff' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0,-1) - , 1, '64BF', 1234.5678, NULL + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0,-1) + , 1, '64BF', 1234.5678, NULL + ) + , '64BF', 987.654321, NULL ) - , '64BF', 987.654321, NULL - ) - , '64BF', 9876.54321, NULL - ), - 'GTiff' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand( + , '64BF', 9876.54321, NULL + ), + 'GTiff' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '64BF', 1234.5678, -9999 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '64BF', 1234.5678, -9999 + ) + , '64BF', 987.654321, -9999 ) - , '64BF', 987.654321, -9999 - ) - , '64BF', 9876.54321, -9999 - ), - 'GTiff' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', 123, NULL), - 'PNG' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 123, NULL), - 'PNG' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', -123, NULL), - 'PNG' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 254, NULL), - 'PNG' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand( + , '64BF', 9876.54321, -9999 + ), + 'GTiff' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', 123, NULL), + 'PNG' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 123, NULL), + 'PNG' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', -123, NULL), + 'PNG' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 254, NULL), + 'PNG' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BSI', 1, -1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BSI', 1, -1 + ) + , 2, '8BSI', 11, -1 ) - , 2, '8BSI', 11, -1 - ) - , 3, '8BSI', 111, -1 - ), - 'PNG', - ARRAY['ZLEVEL=1'] - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand( + , 3, '8BSI', 111, -1 + ), + 'PNG', + ARRAY['ZLEVEL=1'] + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BSI', 1, -1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BSI', 1, -1 + ) + , 2, '8BSI', 11, -1 ) - , 2, '8BSI', 11, -1 - ) - , 3, '8BSI', 111, -1 - ), - 'PNG', - ARRAY['ZLEVEL=9'] - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', 123, NULL), - 'JPEG' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 123, NULL), - 'JPEG' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', -123, NULL), - 'JPEG' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 254, NULL), - 'JPEG' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand( + , 3, '8BSI', 111, -1 + ), + 'PNG', + ARRAY['ZLEVEL=9'] + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', 123, NULL), + 'JPEG' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 123, NULL), + 'JPEG' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', -123, NULL), + 'JPEG' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 254, NULL), + 'JPEG' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BSI', 1, -1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BSI', 1, -1 + ) + , 2, '8BSI', 11, -1 ) - , 2, '8BSI', 11, -1 - ) - , 3, '8BSI', 111, -1 - ), - 'JPEG' - ) -); -SELECT md5( - ST_AsGDALRaster( - ST_AddBand( + , 3, '8BSI', 111, -1 + ), + 'JPEG' + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsGDALRaster( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BSI', 1, -1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BSI', 1, -1 + ) + , 2, '8BSI', 11, -1 ) - , 2, '8BSI', 11, -1 - ) - , 3, '8BSI', 111, -1 - ), - 'JPEG', - ARRAY['QUALITY=90','PROGRESSIVE=ON'] - ) -); + , 3, '8BSI', 111, -1 + ), + 'JPEG', + ARRAY['QUALITY=90','PROGRESSIVE=ON'] + ) + ) > 0 + THEN 1 + ELSE 0 +END; diff --git a/raster/test/regress/rt_asgdalraster_expected b/raster/test/regress/rt_asgdalraster_expected index f6bc732dd..1d9e4767a 100644 --- a/raster/test/regress/rt_asgdalraster_expected +++ b/raster/test/regress/rt_asgdalraster_expected @@ -1,15 +1,15 @@ -2fd5de5f94416f2999fc24fbc3974a4b -4af1ca04adf045690fb60764cc93de75 -81de10108dd8eede75ef47c8f6f09bc5 -55279950e29968bcf36b2c11ce8bf88b -55279950e29968bcf36b2c11ce8bf88b -4ae84e77caa1a35aa4da233e83feb746 -24188762b5745acda4aa7b92776e7280 -da3c4e827b617f9d7cd83d5759f1d781 -0d6d88030359474c2e86280a65e5e90a -f0de16a21de438249ec0bbd28eafe63c -f0de16a21de438249ec0bbd28eafe63c -ed4e4d60d2ccc82c4597e80c1f97272f -83b6012757444ff7786b5e8473e6cea3 -b699be9f7045656edbb14ecec1c75b5a -96a96f9a6d31544dfc5ba5cd25f40934 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 diff --git a/raster/test/regress/rt_asjpeg.sql b/raster/test/regress/rt_asjpeg.sql index 17f1405f9..696c69f22 100644 --- a/raster/test/regress/rt_asjpeg.sql +++ b/raster/test/regress/rt_asjpeg.sql @@ -1,81 +1,113 @@ -SELECT md5( - ST_AsJPEG( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', 123, NULL) - ) -); -SELECT md5( - ST_AsJPEG( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 123, NULL) - ) -); -SELECT md5( - ST_AsJPEG( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', -123, NULL) - ) -); -SELECT md5( - ST_AsJPEG( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 254, NULL) - ) -); -SELECT md5( - ST_AsJPEG( - ST_AddBand( +SELECT CASE + WHEN length( + ST_AsJPEG( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', 123, NULL) + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsJPEG( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 123, NULL) + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsJPEG( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', -123, NULL) + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsJPEG( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 254, NULL) + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsJPEG( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BUI', 1, 255 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BUI', 1, 255 + ) + , 2, '8BUI', 11, 0 ) - , 2, '8BUI', 11, 0 + , 3, '8BUI', 111, 127 ) - , 3, '8BUI', 111, 127 ) - ) -); -SELECT md5( - ST_AsJPEG( - ST_AddBand( + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsJPEG( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BSI', 1, -1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BSI', 1, -1 + ) + , 2, '8BSI', 11, -1 ) - , 2, '8BSI', 11, -1 - ) - , 3, '8BSI', 111, -1 - ), - ARRAY['QUALITY=90','PROGRESSIVE=ON'] - ) -); -SELECT md5( - ST_AsJPEG( - ST_AddBand( + , 3, '8BSI', 111, -1 + ), + ARRAY['QUALITY=90','PROGRESSIVE=ON'] + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsJPEG( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BSI', 1, -1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BSI', 1, -1 + ) + , 2, '8BSI', 11, -1 ) - , 2, '8BSI', 11, -1 - ) - , 3, '8BSI', 111, -1 - ), - ARRAY[3,1], - 50 - ) -); -SELECT md5( - ST_AsJPEG( - ST_AddBand( + , 3, '8BSI', 111, -1 + ), + ARRAY[3,1], + 50 + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsJPEG( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BSI', 1, -1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BSI', 1, -1 + ) + , 2, '8BSI', 11, -1 ) - , 2, '8BSI', 11, -1 - ) - , 3, '8BUI', 111, -1 - ), - ARRAY[3], - 10 - ) -); + , 3, '8BUI', 111, -1 + ), + ARRAY[3], + 10 + ) + ) > 0 + THEN 1 + ELSE 0 +END; diff --git a/raster/test/regress/rt_asjpeg_expected b/raster/test/regress/rt_asjpeg_expected index e84e5bbc6..144c30e3c 100644 --- a/raster/test/regress/rt_asjpeg_expected +++ b/raster/test/regress/rt_asjpeg_expected @@ -1,9 +1,9 @@ ERROR: The pixel type of band 1 in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type. -f0de16a21de438249ec0bbd28eafe63c +1 ERROR: The pixel type of band 1 in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type. -83b6012757444ff7786b5e8473e6cea3 +1 NOTICE: The JPEG format only permits one or three bands. The first band will be used. -bca07d85db735e4eaf2334969a548b10 +1 ERROR: The pixel type of band 1 in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type. ERROR: The pixel type of band 1 in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type. -d687ffc7b8dcb3ef05cd4fe99656e45d +1 diff --git a/raster/test/regress/rt_aspng.sql b/raster/test/regress/rt_aspng.sql index 898c410e5..4b5973f87 100644 --- a/raster/test/regress/rt_aspng.sql +++ b/raster/test/regress/rt_aspng.sql @@ -1,94 +1,130 @@ -SELECT md5( - ST_AsPNG( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', 123, NULL) - ) -); -SELECT md5( - ST_AsPNG( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 123, NULL) - ) -); -SELECT md5( - ST_AsPNG( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', -123, NULL) - ) -); -SELECT md5( - ST_AsPNG( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 254, NULL) - ) -); -SELECT md5( - ST_AsPNG( - ST_AddBand( +SELECT CASE + WHEN length( + ST_AsPNG( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', 123, NULL) + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsPNG( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 123, NULL) + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsPNG( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', -123, NULL) + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsPNG( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 254, NULL) + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsPNG( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BSI', 1, -1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BSI', 1, -1 + ) + , 2, '8BSI', 11, -1 ) - , 2, '8BSI', 11, -1 - ) - , 3, '8BSI', 111, -1 - ), - ARRAY['ZLEVEL=1'] - ) -); -SELECT md5( - ST_AsPNG( - ST_AddBand( + , 3, '8BSI', 111, -1 + ), + ARRAY['ZLEVEL=1'] + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsPNG( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BSI', 1, -1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BSI', 1, -1 + ) + , 2, '8BSI', 11, -1 ) - , 2, '8BSI', 11, -1 - ) - , 3, '8BSI', 111, -1 - ), - ARRAY['ZLEVEL=9'] - ) -); -SELECT md5( - ST_AsPNG( - ST_AddBand( + , 3, '8BSI', 111, -1 + ), + ARRAY['ZLEVEL=9'] + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsPNG( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BSI', 1, 1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BSI', 1, 1 + ) + , 2, '8BSI', 11, 1 ) - , 2, '8BSI', 11, 1 - ) - , 3, '8BSI', 111, 1 - ), - ARRAY['ZLEVEL=9'] - ) -); -SELECT md5( - ST_AsPNG( - ST_AddBand( - ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '8BUI', 1, 1 - ) - , 2, '8BUI', 11, 1 - ), - ARRAY[1], - 6 - ) -); -SELECT md5( - ST_AsPNG( - ST_AddBand( + , 3, '8BSI', 111, 1 + ), + ARRAY['ZLEVEL=9'] + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsPNG( ST_AddBand( ST_AddBand( ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) , 1, '8BUI', 1, 1 ) , 2, '8BUI', 11, 1 - ) - , 3, '8BUI', 111, 1 - ), - ARRAY[3,1], - 6 - ) -); + ), + ARRAY[1], + 6 + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsPNG( + ST_AddBand( + ST_AddBand( + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '8BUI', 1, 1 + ) + , 2, '8BUI', 11, 1 + ) + , 3, '8BUI', 111, 1 + ), + ARRAY[3,1], + 6 + ) + ) > 0 + THEN 1 + ELSE 0 +END; diff --git a/raster/test/regress/rt_aspng_expected b/raster/test/regress/rt_aspng_expected index fbb91e0f3..5cdb3c0a9 100644 --- a/raster/test/regress/rt_aspng_expected +++ b/raster/test/regress/rt_aspng_expected @@ -1,10 +1,10 @@ ERROR: The pixel type of band 1 in the raster is not 8BUI or 16BUI. The PNG format can only be used with 8BUI and 16BUI pixel types. -55279950e29968bcf36b2c11ce8bf88b +1 ERROR: The pixel type of band 1 in the raster is not 8BUI or 16BUI. The PNG format can only be used with 8BUI and 16BUI pixel types. -24188762b5745acda4aa7b92776e7280 +1 ERROR: The pixel type of band 1 in the raster is not 8BUI or 16BUI. The PNG format can only be used with 8BUI and 16BUI pixel types. ERROR: The pixel type of band 1 in the raster is not 8BUI or 16BUI. The PNG format can only be used with 8BUI and 16BUI pixel types. ERROR: The pixel type of band 1 in the raster is not 8BUI or 16BUI. The PNG format can only be used with 8BUI and 16BUI pixel types. -dfff54767aad7aa842f45e5b83326f0b +1 NOTICE: The PNG format only permits one or three bands. The first band will be used. -58168aa11f7ccdf095e5ed02bde1e676 +1 diff --git a/raster/test/regress/rt_astiff.sql b/raster/test/regress/rt_astiff.sql index 6f9a1c733..1811157ad 100644 --- a/raster/test/regress/rt_astiff.sql +++ b/raster/test/regress/rt_astiff.sql @@ -1,91 +1,119 @@ -SELECT md5( - ST_AsTIFF( - ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '64BF', 123.4567, NULL) - ) -); -SELECT md5( - ST_AsTIFF( - ST_AddBand( +SELECT CASE + WHEN length( + ST_AsTIFF( + ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '64BF', 123.4567, NULL) + ) + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsTIFF( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0,-1) - , 1, '64BF', 1234.5678, NULL + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0,-1) + , 1, '64BF', 1234.5678, NULL + ) + , '64BF', 987.654321, NULL ) - , '64BF', 987.654321, NULL + , '64BF', 9876.54321, NULL ) - , '64BF', 9876.54321, NULL ) - ) -); -SELECT md5( - ST_AsTIFF( - ST_AddBand( + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsTIFF( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '64BF', 1234.5678, -9999 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '64BF', 1234.5678, -9999 + ) + , '64BF', 987.654321, -9999 ) - , '64BF', 987.654321, -9999 + , '64BF', 9876.54321, -9999 ) - , '64BF', 9876.54321, -9999 ) - ) -); -SELECT md5( - ST_AsTIFF( - ST_AddBand( + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsTIFF( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '64BF', 1234.5678, -9999 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '64BF', 1234.5678, -9999 + ) + , '64BF', 987.654321, -9999 ) - , '64BF', 987.654321, -9999 + , '64BF', 9876.54321, -9999 ) - , '64BF', 9876.54321, -9999 + , ARRAY[3] ) - , ARRAY[3] - ) -); -SELECT md5( - ST_AsTIFF( - ST_AddBand( + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsTIFF( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '64BF', 1234.5678, -9999 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '64BF', 1234.5678, -9999 + ) + , '64BF', 987.654321, -9999 ) - , '64BF', 987.654321, -9999 + , '64BF', 9876.54321, -1 ) - , '64BF', 9876.54321, -1 ) - ) -); -SELECT md5( - ST_AsTIFF( - ST_AddBand( + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsTIFF( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '64BF', 1234.5678, -1 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '64BF', 1234.5678, -1 + ) + , '64BF', 987.654321, -9999 ) - , '64BF', 987.654321, -9999 + , '64BF', 9876.54321, -9999 ) - , '64BF', 9876.54321, -9999 ) - ) -); -SELECT md5( - ST_AsTIFF( - ST_AddBand( + ) > 0 + THEN 1 + ELSE 0 +END; +SELECT CASE + WHEN length( + ST_AsTIFF( ST_AddBand( ST_AddBand( - ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) - , 1, '64BF', 1234.5678, -9999 + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) + , 1, '64BF', 1234.5678, -9999 + ) + , '64BF', 987.654321, -9999 ) - , '64BF', 987.654321, -9999 + , '64BF', 9876.54321, -1 ) - , '64BF', 9876.54321, -1 + , 'JPEG90' ) - , 'JPEG90' - ) -); + ) > 0 + THEN 1 + ELSE 0 +END; diff --git a/raster/test/regress/rt_astiff_expected b/raster/test/regress/rt_astiff_expected index f046c10a0..0387b8312 100644 --- a/raster/test/regress/rt_astiff_expected +++ b/raster/test/regress/rt_astiff_expected @@ -1,10 +1,10 @@ -2fd5de5f94416f2999fc24fbc3974a4b -4af1ca04adf045690fb60764cc93de75 -81de10108dd8eede75ef47c8f6f09bc5 -915b9a5f0b1baea454eef06a2431891b +1 +1 +1 +1 NOTICE: The TIFF format only permits one NODATA value for all bands. The value used will be the last band with a NODATA value. -81de10108dd8eede75ef47c8f6f09bc5 +1 NOTICE: The TIFF format only permits one NODATA value for all bands. The value used will be the last band with a NODATA value. NOTICE: The TIFF format only permits one NODATA value for all bands. The value used will be the last band with a NODATA value. -8f6e8ae14b92e32d4cf70c85ef67252e +1 ERROR: The pixel type of band 1 in the raster is not 8BUI. JPEG compression can only be used with the 8BUI pixel type. diff --git a/raster/test/regress/testgdalraster.in b/raster/test/regress/testgdalraster.in new file mode 100644 index 000000000..ecb3a3f60 --- /dev/null +++ b/raster/test/regress/testgdalraster.in @@ -0,0 +1,164 @@ +#!/bin/bash + +POSTGIS_SRC=@POSTGIS_SRC@ +RTGDAL=${POSTGIS_SRC}/raster/scripts/python/rtgdalraster.py +DB=postgis_reg +DBENABLERS="${POSTGIS_SRC}/postgis/postgis.sql ../../rt_pg/rtpostgis.sql" + +PSQL=`which psql` +GDALINFO=`which gdalinfo` + +OPT_DROP=yes +OPT_CREATE=yes + +# create temp +if [ -z "$TMPDIR" ]; then + TMPDIR=/tmp/pgis_reg_$$ +fi + +mkdir -p ${TMPDIR} +echo "TMPDIR is ${TMPDIR}" +echo + +TESTFILE=${POSTGIS_SRC}/raster/test/regress/testgdalraster.test +EXPECTEDFILE=${POSTGIS_SRC}/raster/test/regress/testgdalraster_expected +CHECKSUMFILE=${TMPDIR}/checksum_log +DIFFFILE=${TMPDIR}/checksum_diff + +# testfile doesn't exist +if [ ! -f $TESTFILE ]; then + exit 1 +fi + +while [ -n "$1" ]; do + if test "$1" = "--nodrop"; then + OPT_DROP=no + shift + continue + elif test "$1" = "--nocreate"; then + OPT_CREATE=no + shift + continue + else + break + fi +done + +# create database +db_exists=`${PSQL} -l | grep -w ${DB}` +if test -z "$db_exists"; then + if test x"$OPT_CREATE" = "xyes"; then + echo "Creating spatial db ${DB} " + + createdb "${DB}" > ${TMPDIR}/regress_log + createlang plpgsql "${DB}" >> ${TMPDIR}/regress_log + for f in $DBENABLERS; do + ${PSQL} -f $f "${DB}" >> ${TMPDIR}/regress_log 2>&1 + done + else + + echo "Database ${DB} does not exist" >&2 + echo "Run w/out the --nocreate flag to create it" >&2 + exit 1 + fi +else + if test x"$OPT_CREATE" = "xyes"; then + echo "Database ${DB} already exist." >&2 + echo "Run with the --nocreate flag to use it " \ + "or drop it and try again." >&2 + exit 1 + else + echo "Using existing database ${DB}" + fi +fi + +libver=`${PSQL} -tAc "select postgis_lib_version()" "${DB}"` +if [ -z "$libver" ]; then + echo + echo " Something went wrong (no postgis installed in ${DB})." + if [ -z "$db_exists" ]; then + echo " For details, check ${TMPDIR}/regress_log" + else + echo " Try dropping the database, it will be recreated" \ + " on next run." + fi + echo + exit 1 +fi + +rtlibver=`${PSQL} -tAc "select postgis_raster_lib_version()" "${DB}"` +if [ -z "$rtlibver" ]; then + echo + echo " Something went wrong (no raster installed in ${DB})." + if [ -z "$db_exists" ]; then + echo " For details, check ${TMPDIR}/regress_log" + else + echo " Try dropping the database, it will be recreated" \ + " on next run." + fi + echo + exit 1 +fi + +LC=`wc -l $TESTFILE | awk '{print $1}'` +for x in `seq $LC`; do + ln=`head -n $x $TESTFILE | tail -n 1` + + FORMAT=GTiff + OPTS= + RASTER= + + while IFS=';' read -ra ELE; do + j=0 + for i in "${ELE[@]}"; do + if [ ${#i} -ne 0 ]; then + case "$j" in + "0") + FORMAT="$i" + ;; + "1") + OPTS="$i" + ;; + "2") + RASTER="$i" + ;; + esac + fi + + let j=j+1 + done + done <<< "$ln" + + if [ ${#RASTER} -eq 0 ]; then + continue + fi + if [ ${#FORMAT} -ne 0 ]; then + FORMAT="-f ${FORMAT}" + fi + if [ ${#OPTS} -ne 0 ]; then + OPTS="-c ${OPTS}" + fi + + #echo "format: "$FORMAT + #echo "opts: "$OPTS + #echo "raster: "$RASTER + + $RTGDAL -d "dbname=${DB}" -r "${RASTER}" ${FORMAT} ${OPTS} -o ${TMPDIR}/q${x} >> ${TMPDIR}/rtgdalraster_log + + $GDALINFO -checksum ${TMPDIR}/q${x} | grep Checksum | cut -c 3- >> ${CHECKSUMFILE} +done + +if test x"$OPT_DROP" = "xyes" -a x"$OPT_CREATE" = "xyes"; then + sleep 1 + dropdb "${DB}" > /dev/null +fi + +echo +if diff -c "${EXPECTEDFILE}" "${CHECKSUMFILE}" > ${DIFFFILE}; then + echo "Test passed." +else + cat ${DIFFFILE} + + echo + echo "Test failed." +fi diff --git a/raster/test/regress/testgdalraster.test b/raster/test/regress/testgdalraster.test new file mode 100644 index 000000000..8fdf2603e --- /dev/null +++ b/raster/test/regress/testgdalraster.test @@ -0,0 +1,15 @@ +;;ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '64BF', 123.4567, NULL) +GTiff;;ST_AddBand( ST_AddBand( ST_AddBand( ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0,-1) , 1, '64BF', 1234.5678, NULL) , '64BF', 987.654321, NULL) , '64BF', 9876.54321, NULL) +GTiff;;ST_AddBand( ST_AddBand( ST_AddBand( ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) , 1, '64BF', 1234.5678, -9999) , '64BF', 987.654321, -9999) , '64BF', 9876.54321, -9999) +PNG;;ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', 123, NULL) +PNG;;ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 123, NULL) +PNG;;ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', -123, NULL) +PNG;;ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 254, NULL) +PNG;ZLEVEL=1;ST_AddBand( ST_AddBand( ST_AddBand( ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) , 1, '8BSI', 1, -1) , 2, '8BSI', 11, -1) , 3, '8BSI', 111, -1) +PNG;ZLEVEL=9;ST_AddBand( ST_AddBand( ST_AddBand( ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) , 1, '8BSI', 1, -1) , 2, '8BSI', 11, -1) , 3, '8BSI', 111, -1) +JPEG;;ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', 123, NULL) +JPEG;;ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 123, NULL) +JPEG;;ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BSI', -123, NULL) +JPEG;;ST_AddBand(ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1), 1, '8BUI', 254, NULL) +JPEG;;ST_AddBand( ST_AddBand( ST_AddBand( ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) , 1, '8BSI', 1, -1) , 2, '8BSI', 11, -1) , 3, '8BSI', 111, -1) +JPEG;QUALITY=90,PROGRESSIVE=ON;ST_AddBand( ST_AddBand( ST_AddBand( ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0, -1) , 1, '8BSI', 1, -1) , 2, '8BSI', 11, -1) , 3, '8BSI', 111, -1) diff --git a/raster/test/regress/testgdalraster_expected b/raster/test/regress/testgdalraster_expected new file mode 100644 index 000000000..0f478e57f --- /dev/null +++ b/raster/test/regress/testgdalraster_expected @@ -0,0 +1,27 @@ +Checksum=39484 +Checksum=64937 +Checksum=32120 +Checksum=13684 +Checksum=64937 +Checksum=32120 +Checksum=13684 +Checksum=39484 +Checksum=39484 +Checksum=28666 +Checksum=53950 +Checksum=40000 +Checksum=46854 +Checksum=35679 +Checksum=40000 +Checksum=46854 +Checksum=35679 +Checksum=39484 +Checksum=39484 +Checksum=28666 +Checksum=53950 +Checksum=40000 +Checksum=46861 +Checksum=35679 +Checksum=40000 +Checksum=46861 +Checksum=35679 -- 2.50.1