]> granicus.if.org Git - postgis/commitdiff
Additional regression tests for ST_AsGDALRaster, ST_GDALDrivers, ST_AsRaster, ST_Resa...
authorBborie Park <bkpark at ucdavis.edu>
Thu, 5 Jan 2012 20:13:12 +0000 (20:13 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Thu, 5 Jan 2012 20:13:12 +0000 (20:13 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8681 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rt_pg.c
raster/test/core/testwkb.c
raster/test/regress/rt_asgdalraster.sql
raster/test/regress/rt_asgdalraster_expected
raster/test/regress/rt_asraster.sql
raster/test/regress/rt_asraster_expected
raster/test/regress/rt_metadata.sql
raster/test/regress/rt_metadata_expected
raster/test/regress/rt_resample.sql
raster/test/regress/rt_resample_expected

index fa13103f83c4c1a4058ac7b4c7116fe67db593c1..7e86ab12428ec81dcd91b2725cf647d158c2f191 100644 (file)
@@ -6714,7 +6714,7 @@ Datum RASTER_asGDALRaster(PG_FUNCTION_ARGS)
 
                        if (j > 0) {
                                /* trim allocation */
-                               options = repalloc(options, (j+1) * sizeof(char *));
+                               options = repalloc(options, (j + 1) * sizeof(char *));
 
                                /* add NULL to end */
                                options[j] = NULL;
@@ -6820,6 +6820,7 @@ Datum RASTER_getGDALDrivers(PG_FUNCTION_ARGS)
                drv_set = rt_raster_gdal_drivers(&drv_count, 1);
                if (NULL == drv_set || !drv_count) {
                        elog(NOTICE, "No GDAL drivers found");
+                       MemoryContextSwitchTo(oldcontext);
                        SRF_RETURN_DONE(funcctx);
                }
 
@@ -6978,7 +6979,7 @@ Datum RASTER_asRaster(PG_FUNCTION_ARGS)
 
        /* Get the geometry */
        if (PG_ARGISNULL(0)) 
-           PG_RETURN_NULL();
+               PG_RETURN_NULL();
 
        pggeom = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        geom = lwgeom_from_gserialized(pggeom);
@@ -7530,7 +7531,8 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
        POSTGIS_RT_DEBUG(3, "RASTER_resample: Starting");
 
        /* pgraster is null, return null */
-       if (PG_ARGISNULL(0)) PG_RETURN_NULL();
+       if (PG_ARGISNULL(0))
+               PG_RETURN_NULL();
        pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
        /* raster */
@@ -7753,7 +7755,8 @@ Datum RASTER_metadata(PG_FUNCTION_ARGS)
        POSTGIS_RT_DEBUG(3, "RASTER_metadata: Starting");
 
        /* pgraster is null, return null */
-       if (PG_ARGISNULL(0)) PG_RETURN_NULL();
+       if (PG_ARGISNULL(0))
+               PG_RETURN_NULL();
        pgraster = (rt_pgraster *) PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(0), 0, sizeof(struct rt_raster_serialized_t));
 
        /* raster */
index 5c32dfac49129f7d5c7908996bdccfd0ad53a600..eaaa7a966eb2a85566cba1a303183d82ada153d6 100644 (file)
@@ -133,7 +133,7 @@ main()
     CHECK_EQUALS(rt_raster_get_height(raster), 8);
 
     out  = rt_raster_to_hexwkb(raster, &len);
-    printf(" in hexwkb len: %u\n", strlen(hexwkb));
+    printf(" in hexwkb len: %u\n", (uint32_t) strlen(hexwkb));
     printf("out hexwkb len: %u\n", len);
     printf(" in hexwkb: %s\n", hexwkb);
     printf("out hexwkb: %s\n", out);
@@ -194,7 +194,7 @@ main()
     }
 
     out  = rt_raster_to_hexwkb(raster, &len);
-    printf(" in hexwkb len: %u\n", strlen(hexwkb));
+    printf(" in hexwkb len: %u\n", (uint32_t) strlen(hexwkb));
     printf("out hexwkb len: %u\n", len);
     CHECK_EQUALS(len, strlen(hexwkb));
 /* would depend on machine endian...
@@ -280,7 +280,7 @@ main()
     }
 
     out  = rt_raster_to_hexwkb(raster, &len);
-    printf(" in hexwkb len: %u\n", strlen(hexwkb));
+    printf(" in hexwkb len: %u\n", (uint32_t) strlen(hexwkb));
     printf("out hexwkb len: %u\n", len);
     CHECK_EQUALS(len, strlen(hexwkb));
 /* would depend on machine endian...
@@ -378,7 +378,7 @@ main()
     }
 
     out  = rt_raster_to_hexwkb(raster, &len);
-    printf(" in hexwkb len: %u\n", strlen(hexwkb));
+    printf(" in hexwkb len: %u\n", (uint32_t) strlen(hexwkb));
     printf("out hexwkb len: %u\n", len);
     CHECK_EQUALS(len, strlen(hexwkb));
 /* would depend on machine endian
@@ -463,7 +463,7 @@ main()
     }
 
     out  = rt_raster_to_hexwkb(raster, &len);
-    printf(" in hexwkb len: %u\n", strlen(hexwkb));
+    printf(" in hexwkb len: %u\n", (uint32_t) strlen(hexwkb));
     printf("out hexwkb len: %u\n", len);
     CHECK_EQUALS(len, strlen(hexwkb));
 /* would depend on machine endian
@@ -523,7 +523,7 @@ main()
     }
 
     out  = rt_raster_to_hexwkb(raster, &len);
-    printf(" in hexwkb len: %u\n", strlen(hexwkb));
+    printf(" in hexwkb len: %u\n", (uint32_t) strlen(hexwkb));
     printf("out hexwkb len: %u\n", len);
     CHECK_EQUALS(len, strlen(hexwkb));
 /* would depend on machine endian
@@ -760,7 +760,7 @@ main()
     }
 
     out  = rt_raster_to_hexwkb(raster, &len);
-    printf(" in hexwkb len: %u\n", strlen(hexwkb));
+    printf(" in hexwkb len: %u\n", (uint32_t) strlen(hexwkb));
     printf("out hexwkb len: %u\n", len);
     CHECK_EQUALS(len, strlen(hexwkb));
 /* would depend on machine endian
index 0429fb355e3396ee500d7bf3bf4a21f1282f4bc1..5f8c99a4716437f76128440af0bdd6b4ae864a45 100644 (file)
@@ -1,3 +1,13 @@
+SELECT CASE
+       WHEN length(
+               ST_AsGDALRaster(
+                       NULL,
+                       'GTiff'
+               )
+       ) > 0
+               THEN 1
+       ELSE 0
+END;
 SELECT CASE
        WHEN length(
                ST_AsGDALRaster(
index 1d9e4767a95047ca5e395714985afaedb186f4cd..37a7fd4cb899a1df1614456b1b2aa682174a630a 100644 (file)
@@ -1,3 +1,4 @@
+0
 1
 1
 1
index 2d610750437f3bf00b444f1b3bcc845060bbcb3f..a4813650175f7e0d76c12307e23bf32f62485795 100644 (file)
@@ -56,6 +56,11 @@ ST_GeomFromText('MULTIPOLYGON(((-172210.499109288 114987.660953018,-175453.08638
 
 -- scale or width & height, pixtype, value and nodata
 INSERT INTO raster_asraster_dst (rid, rast) VALUES (
+       1.0, (SELECT ST_AsRaster(
+               NULL,
+               100, 100
+       ))
+), (
        1.1, (SELECT ST_AsRaster(
                geom,
                100, 100
@@ -190,6 +195,15 @@ INSERT INTO raster_asraster_dst (rid, rast) VALUES (
 
 -- upper left
 INSERT INTO raster_asraster_dst (rid, rast) VALUES (
+       2.0, (SELECT ST_AsRaster(
+               NULL,
+               1000., -1000.,
+               '8BUI',
+               255,
+               0,
+               -175453
+       ))
+), (
        2.1, (SELECT ST_AsRaster(
                geom,
                1000., -1000.,
@@ -256,6 +270,16 @@ INSERT INTO raster_asraster_dst (rid, rast) VALUES (
 
 -- skew
 INSERT INTO raster_asraster_dst (rid, rast) VALUES (
+       3.0, (SELECT ST_AsRaster(
+               NULL,
+               100, 100,
+               '8BUI',
+               255,
+               0,
+               NULL, NULL,
+               0
+       ))
+), (
        3.1, (SELECT ST_AsRaster(
                geom,
                100, 100,
@@ -319,6 +343,14 @@ INSERT INTO raster_asraster_dst (rid, rast) VALUES (
 
 -- snap to grid
 INSERT INTO raster_asraster_dst (rid, rast) VALUES (
+       4.0, (
+               SELECT ST_AsRaster(
+                       NULL,
+                       rast
+               )
+               FROM raster_asraster_rast
+       )
+), (
        4.1, (
                SELECT ST_AsRaster(
                        geom,
index 01aef4c5c87bbff7b60d906462dd89970e1eff1e..4507f51a1f522e9b9261090039c40840b895c54c 100644 (file)
@@ -10,6 +10,7 @@ NOTICE:  The geometry's SRID (993310) is not the same as the raster's SRID (9921
 NOTICE:  The geometry's SRID (993310) is not the same as the raster's SRID (992163).  The geometry will be transformed to the raster's projection
 NOTICE:  The geometry's SRID (993310) is not the same as the raster's SRID (992163).  The geometry will be transformed to the raster's projection
 NOTICE:  The geometry's SRID (993310) is not the same as the raster's SRID (992163).  The geometry will be transformed to the raster's projection
+1.0||||||||||||||||
 1.1|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|1.000|1.000
 1.10|993310|141|87|1|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|32BF|t|0.000|t|1.000|1.000
 1.11|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|1.000|1.000
@@ -30,6 +31,7 @@ NOTICE:  The geometry's SRID (993310) is not the same as the raster's SRID (9921
 1.7|993310|1407|869|1|100.000|-100.000|0.000|0.000|-175453.086|114987.661|32BF|t|0.000|t|1.000|1.000
 1.8|993310|141|87|1|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|1.000|1.000
 1.9|993310|141|87|1|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|16BUI|t|0.000|t|1.000|1.000
+2.0||||||||||||||||
 2.1||||||||||||||||
 2.2|993310|141|87|1|1000.000|-1000.000|0.000|0.000|-175400.000|115000.000|8BUI|t|0.000|t|255.000|255.000
 2.3|993310|135|87|1|1000.000|-1000.000|0.000|0.000|-170000.000|114988.000|8BUI|t|0.000|t|255.000|255.000
@@ -37,12 +39,14 @@ NOTICE:  The geometry's SRID (993310) is not the same as the raster's SRID (9921
 2.5|993310|144|91|1|1000.000|-1000.000|0.000|0.000|-179000.000|119000.000|8BUI|t|0.000|t|255.000|255.000
 2.6|993310|100|100|1|1406.537|-869.114|0.000|0.000|-179000.000|119000.000|8BUI|t|0.000|t|255.000|255.000
 2.7|993310|100|100|1|1406.537|-869.114|0.000|0.000|-179000.000|119000.000|8BUI|t|0.000|t|255.000|255.000
+3.0||||||||||||||||
 3.1|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|255.000|255.000
 3.2|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|255.000|255.000
 3.3|993310|100|100|1|1406.537|-869.114|1.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|255.000|255.000
 3.4|993310|100|100|1|1406.537|-869.114|0.000|1.000|-175453.086|114987.661|8BUI|t|0.000|t|255.000|255.000
 3.5|993310|100|100|1|1406.537|-869.114|10.000|-5.000|-175453.086|114987.661|8BUI|t|0.000|t|255.000|255.000
 3.6|993310|100|100|1|1406.537|-869.114|-5.000|10.000|-175453.086|114987.661|8BUI|t|0.000|t|255.000|255.000
+4.0||||||||||||||||
 4.1|992163|150|116|1|1000.000|-1000.000|0.000|0.000|-1898000.000|-412000.000|8BUI|t|0.000|t|1.000|1.000
 4.10|993310|141|87|1|1000.000|-1000.000|0.000|0.000|-176100.000|115100.000|16BUI|t|0.000|t|13.000|13.000
 4.11|993310|141|87|1|1000.000|-1000.000|0.000|0.000|-176100.000|115100.000|16BUI|t|0.000|t|13.000|13.000
index 62e885e4f8cce6a7c146b66ee503c5be9d19107c..b3ca8422a7d596b032868f0ce606a1e1c26b2ad2 100644 (file)
@@ -1,3 +1,4 @@
+SELECT * FROM ST_MetaData(NULL);
 SELECT * FROM ST_MetaData(
        ST_AddBand(
                ST_MakeEmptyRaster(10, 10, 10, 10, 2, 2, 0, 0,-1)
index a51807bc71320d9814ed443d6a2f7a897425c0e3..59e38b89c8636b73a31e2653e375ae564ace9bd6 100644 (file)
@@ -1 +1,2 @@
+|||||||||
 10|10|10|10|2|2|0|0|-1|1
index 408a22046729832cfe5f54c404d0e36f2c9d69fd..935608d5d583f275ea767cc09f5a7b89416adec8 100644 (file)
@@ -47,6 +47,10 @@ INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4tex
 
 -- ST_Resample
 INSERT INTO raster_resample_dst (rid, rast) VALUES (
+       1.0, (SELECT ST_Resample(
+               NULL
+       ))
+), (
        1.1, (SELECT ST_Resample(
                rast
        ) FROM raster_resample_src)
@@ -237,6 +241,12 @@ INSERT INTO raster_resample_dst (rid, rast) VALUES (
                ST_MakeEmptyRaster(5, 5, -654321, 123456, 100, 100, 0, 0, 992163),
                FALSE
        ) FROM raster_resample_src)
+), (
+       1.29, (SELECT ST_Resample(
+               rast,
+               NULL::raster,
+               FALSE
+       ) FROM raster_resample_src)
 );
 
 -- ST_Transform
index 34e99eef5c5965030be18692ecdc025119d72de5..426b571e1ac4b99700e975c50a08943b39d87802 100644 (file)
@@ -2,6 +2,7 @@ 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 when specifying the scale.  Returning original raster
 NOTICE:  Values must be provided for both X and Y when specifying the scale.  Returning original raster
+1.0|||||||||||||
 1.1|992163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t
 1.10|992163|40|40|1|250.000|-250.000|0.000|0.000|-500000.000|600000.000|t|t|t
 1.11|992163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t
@@ -23,6 +24,7 @@ NOTICE:  Values must be provided for both X and Y when specifying the scale.  Re
 1.26|992163|150|150|1|66.667|-66.667|0.000|0.000|-500000.000|600000.000|t|t|t
 1.27|993310|150|150|1|80.792|-80.792|0.000|0.000|950732.188|1409281.783|t|t|t
 1.28|992163|5|5|1|2064.200|-2291.200|0.000|0.000|-500321.000|601456.000|t|t|t
+1.29|||||||||||||
 1.3|993309|12|12|1|1009.916|-1009.916|0.000|0.000|950762.305|1409088.896|t|t|t
 1.4|994269|12|8|1|0.012|-0.012|0.000|0.000|-107.029|50.206|t|t|t
 1.5|993310|24|24|1|500.000|-500.000|0.000|0.000|950732.188|1409281.783|t|t|t