Commit 43938cd3 authored by Bborie Park's avatar Bborie Park

Additional regression tests for ST_AsGDALRaster, ST_GDALDrivers, ST_AsRaster,...

Additional regression tests for ST_AsGDALRaster, ST_GDALDrivers, ST_AsRaster, ST_Resample, ST_Metadata.  Syntax cleanup in rt_pg.c and testwkb.c


git-svn-id: http://svn.osgeo.org/postgis/trunk@8681 b70326c6-7e19-0410-871a-916f4a2858ee
parent 6cfe4e29
......@@ -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 */
......
......@@ -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
......
SELECT CASE
WHEN length(
ST_AsGDALRaster(
NULL,
'GTiff'
)
) > 0
THEN 1
ELSE 0
END;
SELECT CASE
WHEN length(
ST_AsGDALRaster(
......
......@@ -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,
......
......@@ -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
......
SELECT * FROM ST_MetaData(NULL);
SELECT * FROM ST_MetaData(
ST_AddBand(
ST_MakeEmptyRaster(10, 10, 10, 10, 2, 2, 0, 0,-1)
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment