Commit 35239b6b authored by Bborie Park's avatar Bborie Park

add unit test for #3020. use rectangular out-db raster

git-svn-id: http://svn.osgeo.org/postgis/trunk@13197 b70326c6-7e19-0410-871a-916f4a2858ee
parent 556c9403
......@@ -23,14 +23,14 @@ CREATE TABLE raster_outdb_template AS
SELECT
1 AS rid,
ST_AddBand( -- insert all three bands of out-db raster at index 1
ST_MakeEmptyRaster(90, 90, 0., 0., 1, -1, 0, 0, 0),
ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0),
1, '$FILERASTER'::text, NULL::int[]
) AS rast
UNION ALL
SELECT
2 AS rid,
ST_AddBand( -- append all three bands of out-db raster
ST_MakeEmptyRaster(90, 90, 0., 0., 1, -1, 0, 0, 0),
ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0),
'$FILERASTER'::text, NULL::int[]
) AS rast
UNION ALL
......@@ -38,7 +38,7 @@ SELECT
3 AS rid,
ST_AddBand( -- append out-db band 2
ST_AddBand( -- in-db band
ST_MakeEmptyRaster(90, 90, 0., 0., 1, -1, 0, 0, 0),
ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0),
1, '8BUI', 1, 0
),
'$FILERASTER'::text, ARRAY[2]::int[]
......@@ -48,7 +48,7 @@ SELECT
4 AS rid,
ST_AddBand( -- append out-db band 2
ST_AddBand( -- in-db band
ST_MakeEmptyRaster(90, 90, 0., 0., 1, -1, 0, 0, 0),
ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0),
1, '8BUI', 1, 0
),
'$FILERASTER'::text, ARRAY[2]::int[],
......
......@@ -21,14 +21,14 @@ CREATE TABLE raster_outdb_template AS \
SELECT \
1 AS rid, \
ST_AddBand( -- insert all three bands of out-db raster at index 1 \
ST_MakeEmptyRaster(90, 90, 0., 0., 1, -1, 0, 0, 0), \
ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0), \
1, '$FILERASTER'::text, NULL::int[] \
) AS rast \
UNION ALL \
SELECT \
2 AS rid, \
ST_AddBand( -- append all three bands of out-db raster \
ST_MakeEmptyRaster(90, 90, 0., 0., 1, -1, 0, 0, 0), \
ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0), \
'$FILERASTER'::text, NULL::int[] \
) AS rast \
UNION ALL \
......@@ -36,7 +36,7 @@ SELECT \
3 AS rid, \
ST_AddBand( -- append out-db band 2 \
ST_AddBand( \
ST_MakeEmptyRaster(90, 90, 0., 0., 1, -1, 0, 0, 0), \
ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0), \
1, '8BUI', 1, 0 \
), \
'$FILERASTER'::text, ARRAY[2]::int[] \
......@@ -46,7 +46,7 @@ SELECT \
4 AS rid, \
ST_AddBand( -- append out-db band 2 \
ST_AddBand( \
ST_MakeEmptyRaster(90, 90, 0., 0., 1, -1, 0, 0, 0), \
ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0), \
1, '8BUI', 1, 0 \
), \
'$FILERASTER'::text, ARRAY[2]::int[], \
......
0|1.0000000000|-1.0000000000|90|90|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -90,0 0,90 0,90 -90,0 -90))
0|1.0000000000|-1.0000000000|90|50|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -50,0 0,90 0,90 -50,0 -50))
POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255
POLYGON((89 -89,90 -89,90 -90,89 -90,89 -89))|0
POLYGON((44 -44,45 -44,45 -45,44 -45,44 -44))|0
POLYGON((89 -49,90 -49,90 -50,89 -50,89 -49))|0
POLYGON((44 -24,45 -24,45 -25,44 -25,44 -24))|0
SELECT srid, scale_x::numeric(16, 10), scale_y::numeric(16, 10), blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values::numeric(16,10)[], out_db, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'loadedrast' AND r_raster_column = 'rast';
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 1)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 90 AND y = 90;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 45 AND y = 45;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 90 AND y = 50;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 45 AND y = 25;
0|1.0000000000|-1.0000000000|90|90|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -90,0 0,90 0,90 -90,0 -90))
0|1.0000000000|-1.0000000000|90|50|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -50,0 0,90 0,90 -50,0 -50))
POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255
POLYGON((89 -89,90 -89,90 -90,89 -90,89 -89))|0
POLYGON((44 -44,45 -44,45 -45,44 -45,44 -44))|0
POLYGON((89 -49,90 -49,90 -50,89 -50,89 -49))|0
POLYGON((44 -24,45 -24,45 -25,44 -25,44 -24))|0
SELECT srid, scale_x::numeric(16, 10), scale_y::numeric(16, 10), blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values::numeric(16,10)[], out_db, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'loadedrast' AND r_raster_column = 'rast';
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 1)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 90 AND y = 90;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 45 AND y = 45;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 90 AND y = 50;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 45 AND y = 25;
0|||||f|f|||||
POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255
POLYGON((89 -89,90 -89,90 -90,89 -90,89 -89))|0
POLYGON((44 -44,45 -44,45 -45,44 -45,44 -44))|0
POLYGON((89 -49,90 -49,90 -50,89 -50,89 -49))|0
POLYGON((44 -24,45 -24,45 -25,44 -25,44 -24))|0
BasicFilename.tif
SELECT srid, scale_x::numeric(16, 10), scale_y::numeric(16, 10), blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values::numeric(16,10)[], out_db, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'loadedrast' AND r_raster_column = 'rast';
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 1)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 90 AND y = 90;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 45 AND y = 45;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 90 AND y = 50;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 45 AND y = 25;
SELECT foobar FROM loadedrast ORDER BY foobar;
0|1.0000000000|-1.0000000000|90|90|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{t,t,t}|POLYGON((0 -90,0 0,90 0,90 -90,0 -90))
0|1.0000000000|-1.0000000000|90|50|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{t,t,t}|POLYGON((0 -50,0 0,90 0,90 -50,0 -50))
POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255
POLYGON((89 -89,90 -89,90 -90,89 -90,89 -89))|0
POLYGON((44 -44,45 -44,45 -45,44 -45,44 -44))|0
POLYGON((89 -49,90 -49,90 -50,89 -50,89 -49))|0
POLYGON((44 -24,45 -24,45 -25,44 -25,44 -24))|0
......@@ -7,5 +7,5 @@ SET postgis.gdal_enabled_drivers = 'GTiff';
DELETE FROM loadedrast WHERE filename != 'testraster.tif';
SELECT srid, scale_x::numeric(16, 10), scale_y::numeric(16, 10), blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values::numeric(16,10)[], out_db, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'loadedrast' AND r_raster_column = 'rast';
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 1)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 90 AND y = 90;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 45 AND y = 45;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 90 AND y = 50;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 45 AND y = 25;
3857
-20000000
-14500000
3857
-20000000
-14500000
0|1.0000000000|-1.0000000000|10|10|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -90,0 0,90 0,90 -90,0 -90))
0|1.0000000000|-1.0000000000|10|10|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -50,0 0,90 0,90 -50,0 -50))
POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255
POLYGON((0 -80,1 -80,1 -81,0 -81,0 -80))|255
POLYGON((80 -80,81 -80,81 -81,80 -81,80 -80))|255
POLYGON((40 -20,41 -20,41 -21,40 -21,40 -20))|0
POLYGON((80 -40,81 -40,81 -41,80 -41,80 -40))|198
SELECT srid, scale_x::numeric(16, 10), scale_y::numeric(16, 10), blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values::numeric(16,10)[], out_db, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'loadedrast' AND r_raster_column = 'rast';
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 1)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 73) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 81) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 23) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 45) foo WHERE x = 1 AND y = 1;
0|1.0000000000|-1.0000000000|10|10|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -90,0 0,90 0,90 -90,0 -90))
0|1.0000000000|-1.0000000000|10|10|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -50,0 0,90 0,90 -50,0 -50))
POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255
POLYGON((0 -80,1 -80,1 -81,0 -81,0 -80))|255
POLYGON((80 -80,81 -80,81 -81,80 -81,80 -80))|255
POLYGON((40 -20,41 -20,41 -21,40 -21,40 -20))|0
POLYGON((80 -40,81 -40,81 -41,80 -41,80 -40))|198
SELECT srid, scale_x::numeric(16, 10), scale_y::numeric(16, 10), blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values::numeric(16,10)[], out_db, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'loadedrast' AND r_raster_column = 'rast';
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 1)).* FROM loadedrast WHERE rid = 1) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 73) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 81) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 23) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 45) foo WHERE x = 1 AND y = 1;
0|1.0000000000|-1.0000000000|8|8|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|t
POLYGON((88 0,89 0,89 -1,88 -1,88 0))|255
POLYGON((88 0,89 0,89 -1,88 -1,88 0))|255
POLYGON((0 -88,1 -88,1 -89,0 -89,0 -88))|255
POLYGON((88 -88,89 -88,89 -89,88 -89,88 -88))|255
POLYGON((88 0,89 0,89 -1,88 -1,88 0))|0
POLYGON((88 0,89 0,89 -1,88 -1,88 0))|90
POLYGON((56 -24,57 -24,57 -25,56 -25,56 -24))|255
POLYGON((88 -48,89 -48,89 -49,88 -49,88 -48))|198
......@@ -10,11 +10,11 @@ SELECT
pixel_types,
nodata_values::numeric(16,10)[],
out_db,
ST_Equals(extent, 'POLYGON((16 -90,8 -90,0 -90,0 -88,0 -80,0 -72,0 -64,0 -56,0 -48,0 -40,0 -32,0 -24,0 -16,0 -8,0 0,8 0,16 0,24 0,32 0,40 0,48 0,56 0,64 0,72 0,80 0,88 0,90 0,90 -8,90 -16,90 -24,90 -32,90 -40,90 -48,90 -56,90 -64,90 -72,90 -80,90 -88,90 -90,88 -90,80 -90,72 -90,64 -90,56 -90,48 -90,40 -90,32 -90,24 -90,16 -90))'::geometry)
ST_Equals(extent, 'POLYGON((0 -50,0 0,90 0,90 -50,0 -50))'::geometry)
FROM raster_columns
WHERE r_table_name = 'loadedrast'
AND r_raster_column = 'rast';
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 1)).* FROM loadedrast WHERE rid = 12) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 12) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 133) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 144) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 2)).* FROM loadedrast WHERE rid = 44) foo WHERE x = 1 AND y = 1;
SELECT ST_AsEWKT(geom), val FROM (SELECT (ST_PixelAsPolygons(rast, 3)).* FROM loadedrast WHERE rid = 84) foo WHERE x = 1 AND y = 1;
......@@ -223,3 +223,38 @@ SELECT
ELSE NULL
END
FROM ST_BandMetadata((SELECT rast FROM raster_outdb_template WHERE rid = 4), ARRAY[]::int[]);
-- #3020
SET postgis.gdal_enabled_drivers = 'GTiff';
SET postgis.enable_outdb_rasters = true;
WITH foo AS (
SELECT
path
FROM ST_BandMetadata(
(SELECT rast FROM raster_outdb_template WHERE rid = 1),
ARRAY[]::int[]
)
LIMIT 1
), raster as (
SELECT
ST_AddBand(
ST_MakeEmptyRaster(90, 90, 0., 0., 1, -1, 0, 0, 0),
1, foo.path, NULL::int[]
) AS rast
FROM foo
)
SELECT
ST_Value(rast, 1, 1)
FROM raster
UNION ALL
SELECT
ST_Value(rast, 6, 45)
FROM raster
UNION ALL
SELECT
ST_Value(rast, 90, 50)
FROM raster
UNION ALL
SELECT
ST_Value(rast, 100, 100)
FROM raster
......@@ -118,3 +118,7 @@ NOTICE: RASTER_copyBand: Could not add band to raster. Returning original raste
3|2|t|t
4|1|t|t
4|2|f|
NOTICE: Attempting to get pixel value with out of range raster coordinates: (99, 99)
255
90
255
......@@ -37,18 +37,18 @@ Raster of 10x10 pixels has 3 bands and extent of BOX(0 -10,10 0)
band 3 of pixtype 16BSI is in-db with no NODATA value
Skewed raster of 10x10 pixels has 1 band and extent of BOX(0 -10,10 0.0001)
band 1 of pixtype 8BUI is in-db with NODATA value of 0
1|Raster of 90x90 pixels has 3 bands and extent of BOX(0 -90,90 0)
1|Raster of 90x50 pixels has 3 bands and extent of BOX(0 -50,90 0)
band 1 of pixtype 8BUI is out-db with no NODATA value
band 2 of pixtype 8BUI is out-db with no NODATA value
band 3 of pixtype 8BUI is out-db with no NODATA value
2|Raster of 90x90 pixels has 3 bands and extent of BOX(0 -90,90 0)
2|Raster of 90x50 pixels has 3 bands and extent of BOX(0 -50,90 0)
band 1 of pixtype 8BUI is out-db with no NODATA value
band 2 of pixtype 8BUI is out-db with no NODATA value
band 3 of pixtype 8BUI is out-db with no NODATA value
3|Raster of 90x90 pixels has 2 bands and extent of BOX(0 -90,90 0)
3|Raster of 90x50 pixels has 2 bands and extent of BOX(0 -50,90 0)
band 1 of pixtype 8BUI is in-db with NODATA value of 0
band 2 of pixtype 8BUI is out-db with no NODATA value
4|Raster of 90x90 pixels has 2 bands and extent of BOX(0 -90,90 0)
4|Raster of 90x50 pixels has 2 bands and extent of BOX(0 -50,90 0)
band 1 of pixtype 8BUI is out-db with NODATA value of 255
band 2 of pixtype 8BUI is in-db with NODATA value of 0
ms1|64
......
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