]> granicus.if.org Git - postgis/commitdiff
- Added test testgdalraster.in which properly tests the output of ST_AsGDALRaster...
authorBborie Park <bkpark at ucdavis.edu>
Tue, 24 May 2011 14:27:08 +0000 (14:27 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 24 May 2011 14:27:08 +0000 (14:27 +0000)
- 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

12 files changed:
raster/test/regress/Makefile.in
raster/test/regress/rt_asgdalraster.sql
raster/test/regress/rt_asgdalraster_expected
raster/test/regress/rt_asjpeg.sql
raster/test/regress/rt_asjpeg_expected
raster/test/regress/rt_aspng.sql
raster/test/regress/rt_aspng_expected
raster/test/regress/rt_astiff.sql
raster/test/regress/rt_astiff_expected
raster/test/regress/testgdalraster.in [new file with mode: 0644]
raster/test/regress/testgdalraster.test [new file with mode: 0644]
raster/test/regress/testgdalraster_expected [new file with mode: 0644]

index d9ab152b2e38ceb3f86df2a9c2d732da3fdcd0ed..c9de18d9da6a3b853334d41114540051e159437a 100644 (file)
@@ -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
index 46eef9d2293bb0daefcebdf44bdde173e2882f6d..d2f5cdd6095a86ad6c6c3bda9814898e39cb84c6 100644 (file)
-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;
index f6bc732dda95f698d4f09d2bf133a5d6940dba65..1d9e4767a95047ca5e395714985afaedb186f4cd 100644 (file)
@@ -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
index 17f1405f9adb480b3c702875a6e6d4974ee08160..696c69f22e449fde04e052ee145c053c9c33384c 100644 (file)
-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;
index e84e5bbc64ab77fc5f744c3ba54ba8d839ebfb53..144c30e3cb913d6f287328ef9a81416b5838001f 100644 (file)
@@ -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
index 898c410e53cdad07c93319936c72a92c9ab1f36e..4b5973f87efe66227eac160b33acb4886e7b8924 100644 (file)
-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;
index fbb91e0f3039e4077bafa48412b0005ae567d9f0..5cdb3c0a96ad26c4aa71c00f8597e4e62cfe1324 100644 (file)
@@ -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
index 6f9a1c7339ebb022d0355b4432077b4f9817a47e..1811157adee456d9d7f1a07cb9604cfcba1fd9e3 100644 (file)
-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;
index f046c10a0cae4931855fdbbb251837ce5d80cc6d..0387b83125e29f9b1c6cf04f8a5cef480d03d865 100644 (file)
@@ -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 (file)
index 0000000..ecb3a3f
--- /dev/null
@@ -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 (file)
index 0000000..8fdf260
--- /dev/null
@@ -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 (file)
index 0000000..0f478e5
--- /dev/null
@@ -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