From: Bborie Park Date: Wed, 25 Jul 2012 03:36:24 +0000 (+0000) Subject: Consolidated create_* and drop_* scripts into respective regression X-Git-Tag: 2.1.0beta2~747 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=433e5f0847a7878c8c06fc128a02963555e390ad;p=postgis Consolidated create_* and drop_* scripts into respective regression tests. Should make things easier to build a valgrind test suite. git-svn-id: http://svn.osgeo.org/postgis/trunk@10117 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/test/regress/Makefile.in b/raster/test/regress/Makefile.in index 779b1aec8..631941872 100644 --- a/raster/test/regress/Makefile.in +++ b/raster/test/regress/Makefile.in @@ -50,7 +50,6 @@ TEST_FUNC = \ rt_aspng TEST_PROPS = \ - create_rt_properties_test \ rt_dimensions \ rt_scale \ rt_pixelsize \ @@ -58,17 +57,13 @@ TEST_PROPS = \ rt_rotation \ rt_georeference \ rt_set_properties \ - drop_rt_properties_test \ - create_rt_empty_raster_test \ rt_isempty \ rt_hasnoband \ - drop_rt_empty_raster_test \ rt_metadata \ rt_raster2worldcoord \ rt_world2rastercoord TEST_BANDPROPS = \ - create_rt_band_properties_test \ rt_band_properties \ rt_set_band_properties \ rt_summarystats \ @@ -79,7 +74,6 @@ TEST_BANDPROPS = \ rt_valuepercent \ rt_bandmetadata \ rt_pixelvalue \ - drop_rt_band_properties_test \ rt_neighborhood \ rt_nearestvalue \ rt_pixelofvalue \ @@ -90,16 +84,12 @@ TEST_BANDPROPS = \ TEST_UTILITY = \ rt_utility \ - create_rt_mapalgebra_test \ rt_mapalgebraexpr \ rt_mapalgebrafct \ rt_mapalgebraexpr_2raster \ rt_mapalgebrafct_2raster \ - drop_rt_mapalgebra_test \ - create_rt_mapalgebrafctngb_test \ rt_mapalgebrafctngb \ rt_mapalgebrafctngb_userfunc \ - drop_rt_mapalgebrafctngb_test \ rt_reclass \ rt_resample \ rt_asraster \ @@ -108,7 +98,6 @@ TEST_UTILITY = \ rt_union TEST_GIST = \ - create_rt_gist_test \ rt_above \ rt_below \ rt_contained \ @@ -120,9 +109,8 @@ TEST_GIST = \ rt_overleft \ rt_overright \ rt_right \ - rt_same \ - drop_rt_gist_test - + rt_same + TEST_SREL = \ rt_intersects \ rt_overlaps \ diff --git a/raster/test/regress/create_rt_band_properties_test.sql b/raster/test/regress/create_rt_band_properties_test.sql deleted file mode 100644 index fd756685a..000000000 --- a/raster/test/regress/create_rt_band_properties_test.sql +++ /dev/null @@ -1,225 +0,0 @@ ------------------------------------------------------------------------ --- $Id$ --- --- Copyright (c) 2009 Pierre Racine --- --- This is free software; you can redistribute and/or modify it under --- the terms of the GNU General Public Licence. See the COPYING file. ------------------------------------------------------------------------ - ------------------------------------------------------------------------ ---- Test of "Get" functions for properties of the raster. ------------------------------------------------------------------------ - -CREATE TABLE rt_band_properties_test ( - id numeric, - description text, - nbband integer, - b1pixeltype text, - b1hasnodatavalue boolean, - b1nodatavalue float4, - b1val float4, - b2pixeltype text, - b2hasnodatavalue boolean, - b2nodatavalue float4, - b2val float4, - geomtxt text, - rast raster -); - -INSERT INTO rt_band_properties_test -VALUES ( 1, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', - 2, --- nbband - '4BUI', true, 3, 2, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val - '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val - 'POLYGON((782325.5 26744042.5,782330.5 26744045.5,782333.5 26744040.5,782328.5 26744037.5,782325.5 26744042.5))', -( -'01' -- big endian (uint8 xdr) -|| -'0000' -- version (uint16 0) -|| -'0200' -- nBands (uint16 2) -|| -'0000000000001440' -- scaleX (float64 5) -|| -'00000000000014C0' -- scaleY (float64 -5) -|| -'00000000EBDF2741' -- ipX (float64 782325.5) -|| -'000000A84E817941' -- ipY (float64 26744042.5) -|| -'0000000000000840' -- skewX (float64 3) -|| -'0000000000000840' -- skewY (float64 3) -|| -'27690000' -- SRID (int32 26919 - UTM 19N) -|| -'0100' -- width (uint16 1) -|| -'0100' -- height (uint16 1) -|| -'4' -- hasnodatavalue set to true -|| -'2' -- first band type (4BUI) -|| -'03' -- novalue==3 -|| -'02' -- pixel(0,0)==2 -|| -'0' -- hasnodatavalue set to false -|| -'5' -- second band type (16BSI) -|| -'0D00' -- novalue==13 -|| -'0400' -- pixel(0,0)==4 -)::raster -); - -INSERT INTO rt_band_properties_test -VALUES ( 2, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', - 2, --- nbband - '4BUI', true, 3, 2, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val - '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val - 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0200' -- nBands (uint16 0) -|| -'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) -|| -'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) -|| -'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) -|| -'718F0E9A27A44840' -- ipY (float64 49.2824585505576) -|| -'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) -|| -'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) -|| -'E6100000' -- SRID (int32 4326) -|| -'0100' -- width (uint16 1) -|| -'0100' -- height (uint16 1) -|| -'4' -- hasnodatavalue set to true -|| -'2' -- first band type (4BUI) -|| -'03' -- novalue==3 -|| -'02' -- pixel(0,0)==2 -|| -'0' -- hasnodatavalue set to false -|| -'5' -- second band type (16BSI) -|| -'0D00' -- novalue==13 -|| -'0400' -- pixel(0,0)==4 -)::raster -); - -INSERT INTO rt_band_properties_test -VALUES ( 3, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', - 2, --- nbband - '4BUI', true, 3, 3, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val - '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val - 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0200' -- nBands (uint16 0) -|| -'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) -|| -'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) -|| -'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) -|| -'718F0E9A27A44840' -- ipY (float64 49.2824585505576) -|| -'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) -|| -'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) -|| -'E6100000' -- SRID (int32 4326) -|| -'0100' -- width (uint16 1) -|| -'0100' -- height (uint16 1) -|| -'6' -- hasnodatavalue and isnodata set to true -|| -'2' -- first band type (4BUI) -|| -'03' -- novalue==3 -|| -'03' -- pixel(0,0)==3 (same that nodata) -|| -'0' -- hasnodatavalue set to false -|| -'5' -- second band type (16BSI) -|| -'0D00' -- novalue==13 -|| -'0400' -- pixel(0,0)==4 -)::raster -); - -INSERT INTO rt_band_properties_test -VALUES ( 4, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', - 2, --- nbband - '4BUI', true, 3, 3, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val - '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val - 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0200' -- nBands (uint16 0) -|| -'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) -|| -'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) -|| -'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) -|| -'718F0E9A27A44840' -- ipY (float64 49.2824585505576) -|| -'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) -|| -'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) -|| -'E6100000' -- SRID (int32 4326) -|| -'0100' -- width (uint16 1) -|| -'0100' -- height (uint16 1) -|| -'4' -- hasnodatavalue set to true and isnodata set to false (should be updated) -|| -'2' -- first band type (4BUI) -|| -'03' -- novalue==3 -|| -'03' -- pixel(0,0)==3 (same that nodata) -|| -'0' -- hasnodatavalue set to false -|| -'5' -- second band type (16BSI) -|| -'0D00' -- novalue==13 -|| -'0400' -- pixel(0,0)==4 -)::raster -); - diff --git a/raster/test/regress/create_rt_band_properties_test_expected b/raster/test/regress/create_rt_band_properties_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/create_rt_empty_raster_test.sql b/raster/test/regress/create_rt_empty_raster_test.sql deleted file mode 100644 index e60a0a91c..000000000 --- a/raster/test/regress/create_rt_empty_raster_test.sql +++ /dev/null @@ -1,16 +0,0 @@ ------------------------------------------------------------------------ --- $Id$ --- --- Copyright (c) 2011 Jorge Arevalo --- --- This is free software; you can redistribute and/or modify it under --- the terms of the GNU General Public Licence. See the COPYING file. ------------------------------------------------------------------------ - -CREATE TABLE empty_raster_test ( - rid numeric, - rast raster -); - -INSERT INTO empty_raster_test -VALUES (1, ST_MakeEmptyRaster( 100, 100, 0.0005, 0.0005, 1, 1, 0, 0, 4326) ); \ No newline at end of file diff --git a/raster/test/regress/create_rt_empty_raster_test_expected b/raster/test/regress/create_rt_empty_raster_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/create_rt_gist_test.sql b/raster/test/regress/create_rt_gist_test.sql deleted file mode 100644 index a83562080..000000000 --- a/raster/test/regress/create_rt_gist_test.sql +++ /dev/null @@ -1,71 +0,0 @@ ------------------------------------------------------------------------ --- $Id$ --- --- Copyright (c) 2009 Sandro Santilli --- --- This is free software; you can redistribute and/or modify it under --- the terms of the GNU General Public Licence. See the COPYING file. ------------------------------------------------------------------------ - ------------------------------------------------------------------------ --- makeTileGrid( , , , --- , ) --- --- Return a set of tuples in the form: --- x int, y int, t raster --- Containing a subdivision of given extent --- into a grid composed by rasters of the given --- dimension in pixels. --- --- TODO: DROP functiona and type at the end of test ------------------------------------------------------------------------ -CREATE TYPE tile AS (x int, y int, tile raster); -CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) - RETURNS SETOF tile -AS -' -DECLARE - gridCols alias for $1; - gridRows alias for $2; - extent alias for $3; - tileWidth alias for $4; - tileHeight alias for $5; - rec tile; - scalex float8; - scaley float8; - ipx float8; - ipy float8; -BEGIN - - -- compute some sizes - -- each tile extent width is extent.width / gridRows - scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; - scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; - - FOR y IN 0..gridRows-1 LOOP - ipy = y*scaley + ST_ymin(extent); - FOR x IN 0..gridCols-1 LOOP - ipx = x*scalex + ST_xmin(extent); - rec.x = x; - rec.y = y; - rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, - scalex, scaley, 0, 0); - RETURN NEXT rec; - END LOOP; - END LOOP; - - RETURN; -END; -' -LANGUAGE 'plpgsql'; - ------------------------------------------------------------------------ --- Create a grid of 10x10 rasters on an extent of -100..100 both axis --- and another on the same extent with 3x3 tiles, to use for queries ------------------------------------------------------------------------ - -CREATE TABLE rt_gist_grid_test AS - SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); - -CREATE TABLE rt_gist_query_test AS - SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); diff --git a/raster/test/regress/create_rt_gist_test_expected b/raster/test/regress/create_rt_gist_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/create_rt_mapalgebra_test.sql b/raster/test/regress/create_rt_mapalgebra_test.sql deleted file mode 100644 index b517582ac..000000000 --- a/raster/test/regress/create_rt_mapalgebra_test.sql +++ /dev/null @@ -1,92 +0,0 @@ -CREATE OR REPLACE FUNCTION ST_TestRaster(ulx float8, uly float8, val float8) - RETURNS raster AS - $$ - DECLARE - BEGIN - RETURN ST_AddBand(ST_MakeEmptyRaster(10, 10, ulx, uly, 1, 1, 0, 0, 0), '32BF', val, -1); - END; - $$ - LANGUAGE 'plpgsql'; - - - -CREATE OR REPLACE FUNCTION raster_plus_twenty(pixel FLOAT, VARIADIC args TEXT[]) - RETURNS FLOAT AS - $$ - BEGIN - IF pixel IS NULL THEN - RAISE NOTICE 'Pixel value is null.'; - END IF; - RETURN pixel + 20; - END; - $$ - LANGUAGE 'plpgsql' IMMUTABLE; - -CREATE OR REPLACE FUNCTION raster_plus_arg1(pixel FLOAT, VARIADIC args TEXT[]) - RETURNS FLOAT AS - $$ - DECLARE - x float := 0; - BEGIN - IF NOT args[1] IS NULL THEN - x := args[1]::float; - END IF; - RETURN pixel + x; - END; - $$ - LANGUAGE 'plpgsql' IMMUTABLE; - -CREATE OR REPLACE FUNCTION raster_polynomial(pixel FLOAT, VARIADIC args TEXT[]) - RETURNS FLOAT AS - $$ - DECLARE - m float := 1; - b float := 0; - BEGIN - IF NOT args[1] is NULL THEN - m := args[1]::float; - END IF; - IF NOT args[2] is NULL THEN - b := args[2]::float; - END IF; - RETURN m * pixel + b; - END; - $$ - LANGUAGE 'plpgsql' IMMUTABLE; - - CREATE OR REPLACE FUNCTION raster_nullage(pixel FLOAT, VARIADIC args TEXT[]) - RETURNS FLOAT AS - $$ - BEGIN - RETURN NULL; - END; - $$ - LANGUAGE 'plpgsql' IMMUTABLE; - - CREATE OR REPLACE FUNCTION raster_x_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]) - RETURNS FLOAT AS - $$ - DECLARE - x float := 0; - BEGIN - IF NOT args[1] IS NULL THEN - x := args[1]::float; - END IF; - RETURN pixel + pos[1] + x; - END; - $$ - LANGUAGE 'plpgsql' IMMUTABLE; - - CREATE OR REPLACE FUNCTION raster_y_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]) - RETURNS FLOAT AS - $$ - DECLARE - x float := 0; - BEGIN - IF NOT args[1] IS NULL THEN - x := args[1]::float; - END IF; - RETURN pixel + pos[2] + x; - END; - $$ - LANGUAGE 'plpgsql' IMMUTABLE; diff --git a/raster/test/regress/create_rt_mapalgebra_test_expected b/raster/test/regress/create_rt_mapalgebra_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/create_rt_mapalgebrafctngb_test.sql b/raster/test/regress/create_rt_mapalgebrafctngb_test.sql deleted file mode 100644 index f4ac7e4e2..000000000 --- a/raster/test/regress/create_rt_mapalgebrafctngb_test.sql +++ /dev/null @@ -1,25 +0,0 @@ --- --- A user callback function that nullifies all cells in the resulting raster. --- -CREATE OR REPLACE FUNCTION ST_Nullage(matrix float[][], nodatamode text, VARIADIC args text[]) - RETURNS float AS - $$ - BEGIN - RETURN NULL; - END; - $$ - LANGUAGE 'plpgsql' IMMUTABLE; - - --- ---Test rasters --- -CREATE OR REPLACE FUNCTION ST_TestRasterNgb(h integer, w integer, val float8) - RETURNS raster AS - $$ - DECLARE - BEGIN - RETURN ST_AddBand(ST_MakeEmptyRaster(h, w, 0, 0, 1, 1, 0, 0, 0), '32BF', val, -1); - END; - $$ - LANGUAGE 'plpgsql'; diff --git a/raster/test/regress/create_rt_mapalgebrafctngb_test_expected b/raster/test/regress/create_rt_mapalgebrafctngb_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/create_rt_properties_test.sql b/raster/test/regress/create_rt_properties_test.sql deleted file mode 100644 index b1ec26895..000000000 --- a/raster/test/regress/create_rt_properties_test.sql +++ /dev/null @@ -1,213 +0,0 @@ ------------------------------------------------------------------------ --- $Id$ --- --- Copyright (c) 2009 Mateusz Loskot --- --- This is free software; you can redistribute and/or modify it under --- the terms of the GNU General Public Licence. See the COPYING file. ------------------------------------------------------------------------ - ------------------------------------------------------------------------ ---- Test of "Get" functions for properties of the raster. ------------------------------------------------------------------------ - -CREATE TABLE rt_properties_test ( - id numeric, - name text, - srid integer, - width integer, - height integer, - scalex double precision, - scaley double precision, - ipx double precision, - ipy double precision, - skewx double precision, - skewy double precision, - rast raster -); - -INSERT INTO rt_properties_test -VALUES ( 0, '10x20, ip:0.5,0.5 scale:2,3 skew:0,0 srid:10 width:10 height:20', - 10, 10, 20, --- SRID, width, height - 2, 3, 0.5, 0.5, 0, 0, --- georeference -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0000' -- nBands (uint16 0) -|| -'0000000000000040' -- scaleX (float64 2) -|| -'0000000000000840' -- scaleY (float64 3) -|| -'000000000000E03F' -- ipX (float64 0.5) -|| -'000000000000E03F' -- ipY (float64 0.5) -|| -'0000000000000000' -- skewX (float64 0) -|| -'0000000000000000' -- skewY (float64 0) -|| -'0A000000' -- SRID (int32 10) -|| -'0A00' -- width (uint16 10) -|| -'1400' -- height (uint16 20) -)::raster -); - -INSERT INTO rt_properties_test -VALUES ( 1, '1x1, ip:2.5,2.5 scale:5,5 skew:0,0, srid:12, width:1, height:1', - 12, 1, 1, --- SRID, width, height - 5, 5, 2.5, 2.5, 0, 0, --- georeference -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0000' -- nBands (uint16 0) -|| -'0000000000001440' -- scaleX (float64 5) -|| -'0000000000001440' -- scaleY (float64 5) -|| -'0000000000000440' -- ipX (float64 2.5) -|| -'0000000000000440' -- ipY (float64 2.5) -|| -'0000000000000000' -- skewX (float64 0) -|| -'0000000000000000' -- skewY (float64 0) -|| -'0C000000' -- SRID (int32 12) -|| -'0100' -- width (uint16 1) -|| -'0100' -- height (uint16 1) -)::raster -); - -INSERT INTO rt_properties_test -VALUES ( 2, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:0, width:1, height:1', - 0, 1, 1, --- SRID, width, height - 5, 5, 7.5, 2.5, 0, 0, --- georeference -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0000' -- nBands (uint16 0) -|| -'0000000000001440' -- scaleX (float64 5) -|| -'0000000000001440' -- scaleY (float64 5) -|| -'0000000000001E40' -- ipX (float64 7.5) -|| -'0000000000000440' -- ipY (float64 2.5) -|| -'0000000000000000' -- skewX (float64 0) -|| -'0000000000000000' -- skewY (float64 0) -|| -'00000000' -- SRID (int32 0) -|| -'0100' -- width (uint16 1) -|| -'0100' -- height (uint16 1) -)::raster -); - -INSERT INTO rt_properties_test -VALUES ( 3, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:-1, width:1, height:1', - 0, 1, 1, --- SRID, width, height - 5, 5, 7.5, 2.5, 0, 0, --- georeference -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0000' -- nBands (uint16 0) -|| -'0000000000001440' -- scaleX (float64 5) -|| -'0000000000001440' -- scaleY (float64 5) -|| -'0000000000001E40' -- ipX (float64 7.5) -|| -'0000000000000440' -- ipY (float64 2.5) -|| -'0000000000000000' -- skewX (float64 0) -|| -'0000000000000000' -- skewY (float64 0) -|| -'00000000' -- SRID (int32 0) -|| -'0100' -- width (uint16 1) -|| -'0100' -- height (uint16 1) -)::raster -); - -INSERT INTO rt_properties_test -VALUES ( 4, '1x1, ip:7.5,2.5 scale:5,5 skew:1,1, srid:-1, width:1, height:1', - 0, 1, 1, --- SRID, width, height - 5, 5, 7.5, 2.5, 1, 1, --- georeference -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0000' -- nBands (uint16 0) -|| -'0000000000001440' -- scaleX (float64 5) -|| -'0000000000001440' -- scaleY (float64 5) -|| -'0000000000001E40' -- ipX (float64 7.5) -|| -'0000000000000440' -- ipY (float64 2.5) -|| -'000000000000F03F' -- skewX (float64 1) -|| -'000000000000F03F' -- skewY (float64 1) -|| -'00000000' -- SRID (int32 0) -|| -'0100' -- width (uint16 1) -|| -'0100' -- height (uint16 1) -)::raster -); - -INSERT INTO rt_properties_test -VALUES ( 5, '1x1, ip:7.5,2.5 scale:5,5 skew:3,7, srid:-1, width:1, height:1', - 0, 1, 1, --- SRID, width, height - 5, 5, 7.5, 2.5, 3, 7, --- georeference -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0000' -- nBands (uint16 0) -|| -'0000000000001440' -- scaleX (float64 5) -|| -'0000000000001440' -- scaleY (float64 5) -|| -'0000000000001E40' -- ipX (float64 7.5) -|| -'0000000000000440' -- ipY (float64 2.5) -|| -'0000000000000840' -- skewX (float64 3) -|| -'0000000000001C40' -- skewY (float64 7) -|| -'00000000' -- SRID (int32 0) -|| -'0100' -- width (uint16 1) -|| -'0100' -- height (uint16 1) -)::raster -); diff --git a/raster/test/regress/create_rt_properties_test_expected b/raster/test/regress/create_rt_properties_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/create_rt_utility_test.sql b/raster/test/regress/create_rt_utility_test.sql deleted file mode 100644 index b0bf90085..000000000 --- a/raster/test/regress/create_rt_utility_test.sql +++ /dev/null @@ -1,151 +0,0 @@ ------------------------------------------------------------------------ --- $Id$ --- --- Copyright (c) 2009 Pierre Racine --- --- This is free software; you can redistribute and/or modify it under --- the terms of the GNU General Public Licence. See the COPYING file. ------------------------------------------------------------------------ - ------------------------------------------------------------------------ ---- Test of "Get" functions for properties of the raster. ------------------------------------------------------------------------ - -CREATE TABLE rt_utility_test ( - id numeric, - name text, - srid integer, - width integer, - height integer, - scalex double precision, - scaley double precision, - ipx double precision, - ipy double precision, - skewx double precision, - skewy double precision, - rast raster -); - -INSERT INTO rt_utility_test -VALUES ( 1, '1217x1156, ip:782325.5,26744042.5 scale:5,-5 skew:0,0 srid:9102707 width:1217 height:1156', - 26919, 1217, 1156, --- SRID, width, height - 5, -5, 782325.5, 26744042.5, 0, 0, --- georeference -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0000' -- nBands (uint16 0) -|| -'0000000000001440' -- scaleX (float64 5) -|| -'00000000000014C0' -- scaleY (float64 -5) -|| -'00000000EBDF2741' -- ipX (float64 782325.5) -|| -'000000A84E817941' -- ipY (float64 26744042.5) -|| -'0000000000000000' -- skewX (float64 0) -|| -'0000000000000000' -- skewY (float64 0) -|| -'27690000' -- SRID (int32 26919 - UTM 19N) -|| -'C104' -- width (uint16 1217) -|| -'8404' -- height (uint16 1156) -)::raster -); - -INSERT INTO rt_utility_test -VALUES ( 2, '1217x1156, ip:782325.5,26744042.5 scale:5,-5 skew:3,3 srid:9102707 width:1217 height:1156', - 26919, 1217, 1156, --- SRID, width, height - 5, -5, 782325.5, 26744042.5, 3, 3, --- georeference -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0000' -- nBands (uint16 0) -|| -'0000000000001440' -- scaleX (float64 5) -|| -'00000000000014C0' -- scaleY (float64 -5) -|| -'00000000EBDF2741' -- ipX (float64 782325.5) -|| -'000000A84E817941' -- ipY (float64 26744042.5) -|| -'0000000000000840' -- skewX (float64 3) -|| -'0000000000000840' -- skewY (float64 3) -|| -'27690000' -- SRID (int32 26919 - UTM 19N) -|| -'C104' -- width (uint16 1217) -|| -'8404' -- height (uint16 1156) -)::raster -); - -INSERT INTO rt_utility_test -VALUES ( 3, '6000x6000, ip:-75,50 scale:0.000833333333333333,-0.000833333333333333 skew:0,0 srid:4326 width:6000 height:6000', - 4326, 6000, 6000, --- SRID, width, height - 0.000833333333333333, -0.000833333333333333, -75, 50, 0, 0, --- georeference -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0000' -- nBands (uint16 0) -|| -'4F1BE8B4814E4B3F' -- scaleX (float64 0.000833333333333333) -|| -'4F1BE8B4814E4BBF' -- scaleY (float64 -0.000833333333333333) -|| -'0000000000C052C0' -- ipX (float64 -75) -|| -'0000000000004940' -- ipY (float64 50) -|| -'0000000000000000' -- skewX (float64 0) -|| -'0000000000000000' -- skewY (float64 0) -|| -'E6100000' -- SRID (int32 4326) -|| -'7017' -- width (uint16 6000) -|| -'7017' -- height (uint16 6000) -)::raster -); - -INSERT INTO rt_utility_test -VALUES ( 4, '6000x6000, ip:-75.5533328537098,49.2824585505576 scale:0.000805965234044584,-0.00080596523404458 skew:0.000211812383858707,0.000211812383858704 srid:4326 width:6000 height:6000', - 4326, 6000, 6000, --- SRID, width, height - 0.000805965234044584, -0.00080596523404458, -75.5533328537098, 49.2824585505576, 0.000211812383858707, 0.000211812383858704, --- georeference -( -'01' -- little endian (uint8 ndr) -|| -'0000' -- version (uint16 0) -|| -'0000' -- nBands (uint16 0) -|| -'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) -|| -'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) -|| -'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) -|| -'718F0E9A27A44840' -- ipY (float64 49.2824585505576) -|| -'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) -|| -'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) -|| -'E6100000' -- SRID (int32 4326) -|| -'7017' -- width (uint16 6000) -|| -'7017' -- height (uint16 6000) -)::raster -); diff --git a/raster/test/regress/drop_rt_band_properties_test.sql b/raster/test/regress/drop_rt_band_properties_test.sql deleted file mode 100644 index 455753b0f..000000000 --- a/raster/test/regress/drop_rt_band_properties_test.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE rt_band_properties_test; diff --git a/raster/test/regress/drop_rt_band_properties_test_expected b/raster/test/regress/drop_rt_band_properties_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/drop_rt_empty_raster_test.sql b/raster/test/regress/drop_rt_empty_raster_test.sql deleted file mode 100644 index 555bf443a..000000000 --- a/raster/test/regress/drop_rt_empty_raster_test.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE empty_raster_test; diff --git a/raster/test/regress/drop_rt_empty_raster_test_expected b/raster/test/regress/drop_rt_empty_raster_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/drop_rt_gist_test.sql b/raster/test/regress/drop_rt_gist_test.sql deleted file mode 100644 index 65fc391d9..000000000 --- a/raster/test/regress/drop_rt_gist_test.sql +++ /dev/null @@ -1,5 +0,0 @@ -DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); -DROP table rt_gist_grid_test; -DROP table rt_gist_query_test; -DROP type tile; - diff --git a/raster/test/regress/drop_rt_gist_test_expected b/raster/test/regress/drop_rt_gist_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/drop_rt_mapalgebra_test.sql b/raster/test/regress/drop_rt_mapalgebra_test.sql deleted file mode 100644 index 245ee3422..000000000 --- a/raster/test/regress/drop_rt_mapalgebra_test.sql +++ /dev/null @@ -1,7 +0,0 @@ -DROP FUNCTION ST_TestRaster(ulx float8, uly float8, val float8); -DROP FUNCTION raster_plus_twenty(pixel FLOAT, VARIADIC args TEXT[]); -DROP FUNCTION raster_plus_arg1(pixel FLOAT, VARIADIC args TEXT[]); -DROP FUNCTION raster_polynomial(pixel FLOAT, VARIADIC args TEXT[]); -DROP FUNCTION raster_nullage(pixel FLOAT, VARIADIC args TEXT[]); -DROP FUNCTION raster_x_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]); -DROP FUNCTION raster_y_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]); diff --git a/raster/test/regress/drop_rt_mapalgebra_test_expected b/raster/test/regress/drop_rt_mapalgebra_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/drop_rt_mapalgebrafctngb_test.sql b/raster/test/regress/drop_rt_mapalgebrafctngb_test.sql deleted file mode 100644 index 391ee2eb1..000000000 --- a/raster/test/regress/drop_rt_mapalgebrafctngb_test.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP FUNCTION ST_Nullage(matrix float[][], nodatamode text, VARIADIC args text[]); -DROP FUNCTION ST_TestRasterNgb(h integer, w integer, val float8); diff --git a/raster/test/regress/drop_rt_mapalgebrafctngb_test_expected b/raster/test/regress/drop_rt_mapalgebrafctngb_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/drop_rt_properties_test.sql b/raster/test/regress/drop_rt_properties_test.sql deleted file mode 100644 index 537cdbb90..000000000 --- a/raster/test/regress/drop_rt_properties_test.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP TABLE rt_properties_test; - diff --git a/raster/test/regress/drop_rt_properties_test_expected b/raster/test/regress/drop_rt_properties_test_expected deleted file mode 100644 index e69de29bb..000000000 diff --git a/raster/test/regress/rt_above.sql b/raster/test/regress/rt_above.sql index 8c395fea2..ad264623d 100644 --- a/raster/test/regress/rt_above.sql +++ b/raster/test/regress/rt_above.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ----------------------------------------------------------------------- -- raster_above ----------------------------------------------------------------------- @@ -35,3 +81,8 @@ SELECT 'X |>> query(1,1)' as op, FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 AND a.tile |>> b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_band_properties.sql b/raster/test/regress/rt_band_properties.sql index a42519f07..80bbe22b3 100644 --- a/raster/test/regress/rt_band_properties.sql +++ b/raster/test/regress/rt_band_properties.sql @@ -11,6 +11,217 @@ --- Test of "Set" functions for properties of a raster band. ----------------------------------------------------------------------- +CREATE TABLE rt_band_properties_test ( + id numeric, + description text, + nbband integer, + b1pixeltype text, + b1hasnodatavalue boolean, + b1nodatavalue float4, + b1val float4, + b2pixeltype text, + b2hasnodatavalue boolean, + b2nodatavalue float4, + b2val float4, + geomtxt text, + rast raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 1, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 2, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((782325.5 26744042.5,782330.5 26744045.5,782333.5 26744040.5,782328.5 26744037.5,782325.5 26744042.5))', +( +'01' -- big endian (uint8 xdr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 2) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'00000000000014C0' -- scaleY (float64 -5) +|| +'00000000EBDF2741' -- ipX (float64 782325.5) +|| +'000000A84E817941' -- ipY (float64 26744042.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000000840' -- skewY (float64 3) +|| +'27690000' -- SRID (int32 26919 - UTM 19N) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'4' -- hasnodatavalue set to true +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'02' -- pixel(0,0)==2 +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 2, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 2, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 0) +|| +'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) +|| +'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) +|| +'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) +|| +'718F0E9A27A44840' -- ipY (float64 49.2824585505576) +|| +'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) +|| +'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) +|| +'E6100000' -- SRID (int32 4326) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'4' -- hasnodatavalue set to true +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'02' -- pixel(0,0)==2 +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 3, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 3, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 0) +|| +'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) +|| +'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) +|| +'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) +|| +'718F0E9A27A44840' -- ipY (float64 49.2824585505576) +|| +'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) +|| +'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) +|| +'E6100000' -- SRID (int32 4326) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'6' -- hasnodatavalue and isnodata set to true +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'03' -- pixel(0,0)==3 (same that nodata) +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 4, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 3, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 0) +|| +'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) +|| +'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) +|| +'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) +|| +'718F0E9A27A44840' -- ipY (float64 49.2824585505576) +|| +'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) +|| +'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) +|| +'E6100000' -- SRID (int32 4326) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'4' -- hasnodatavalue set to true and isnodata set to false (should be updated) +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'03' -- pixel(0,0)==3 (same that nodata) +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); ----------------------------------------------------------------------- --- ST_BandPixelType @@ -69,3 +280,4 @@ SELECT FROM rt_band_properties_test WHERE id = 4; +DROP TABLE rt_band_properties_test; diff --git a/raster/test/regress/rt_below.sql b/raster/test/regress/rt_below.sql index 46adc5014..c64f43c22 100644 --- a/raster/test/regress/rt_below.sql +++ b/raster/test/regress/rt_below.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ------------------------------------------------------------------- -- raster_below ----------------------------------------------------------------------- @@ -36,3 +82,8 @@ SELECT 'X <<| query(1,1)' as op, FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 AND a.tile <<| b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_contain.sql b/raster/test/regress/rt_contain.sql index d9a3755cb..db7eb76c6 100644 --- a/raster/test/regress/rt_contain.sql +++ b/raster/test/regress/rt_contain.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ------------------------------------------------------------------- -- raster_contain ----------------------------------------------------------------------- @@ -96,3 +142,8 @@ SELECT 'query(1,1) ~ X' as op, FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 AND b.tile::geometry ~ a.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_contained.sql b/raster/test/regress/rt_contained.sql index 052947fba..9a282f034 100644 --- a/raster/test/regress/rt_contained.sql +++ b/raster/test/regress/rt_contained.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ------------------------------------------------------------------- -- raster_contained ----------------------------------------------------------------------- @@ -36,3 +82,8 @@ SELECT 'X @ query(1,1)' as op, FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 AND a.tile @ b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_dimensions.sql b/raster/test/regress/rt_dimensions.sql index 6dc4eb689..878b72a8e 100644 --- a/raster/test/regress/rt_dimensions.sql +++ b/raster/test/regress/rt_dimensions.sql @@ -7,6 +7,207 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TABLE rt_properties_test ( + id numeric, + name text, + srid integer, + width integer, + height integer, + scalex double precision, + scaley double precision, + ipx double precision, + ipy double precision, + skewx double precision, + skewy double precision, + rast raster +); + +INSERT INTO rt_properties_test +VALUES ( 0, '10x20, ip:0.5,0.5 scale:2,3 skew:0,0 srid:10 width:10 height:20', + 10, 10, 20, --- SRID, width, height + 2, 3, 0.5, 0.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000000040' -- scaleX (float64 2) +|| +'0000000000000840' -- scaleY (float64 3) +|| +'000000000000E03F' -- ipX (float64 0.5) +|| +'000000000000E03F' -- ipY (float64 0.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0A000000' -- SRID (int32 10) +|| +'0A00' -- width (uint16 10) +|| +'1400' -- height (uint16 20) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 1, '1x1, ip:2.5,2.5 scale:5,5 skew:0,0, srid:12, width:1, height:1', + 12, 1, 1, --- SRID, width, height + 5, 5, 2.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000000440' -- ipX (float64 2.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0C000000' -- SRID (int32 12) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 2, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:0, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 3, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 4, '1x1, ip:7.5,2.5 scale:5,5 skew:1,1, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 1, 1, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'000000000000F03F' -- skewX (float64 1) +|| +'000000000000F03F' -- skewY (float64 1) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 5, '1x1, ip:7.5,2.5 scale:5,5 skew:3,7, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 3, 7, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000001C40' -- skewY (float64 7) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + ----------------------------------------------------------------------- --- st_width ----------------------------------------------------------------------- @@ -22,3 +223,5 @@ SELECT id, name, width SELECT id, name, height FROM rt_properties_test WHERE st_height(rast) != height; + +DROP TABLE rt_properties_test; diff --git a/raster/test/regress/rt_georeference.sql b/raster/test/regress/rt_georeference.sql index 845593910..98b18297f 100644 --- a/raster/test/regress/rt_georeference.sql +++ b/raster/test/regress/rt_georeference.sql @@ -7,6 +7,207 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TABLE rt_properties_test ( + id numeric, + name text, + srid integer, + width integer, + height integer, + scalex double precision, + scaley double precision, + ipx double precision, + ipy double precision, + skewx double precision, + skewy double precision, + rast raster +); + +INSERT INTO rt_properties_test +VALUES ( 0, '10x20, ip:0.5,0.5 scale:2,3 skew:0,0 srid:10 width:10 height:20', + 10, 10, 20, --- SRID, width, height + 2, 3, 0.5, 0.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000000040' -- scaleX (float64 2) +|| +'0000000000000840' -- scaleY (float64 3) +|| +'000000000000E03F' -- ipX (float64 0.5) +|| +'000000000000E03F' -- ipY (float64 0.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0A000000' -- SRID (int32 10) +|| +'0A00' -- width (uint16 10) +|| +'1400' -- height (uint16 20) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 1, '1x1, ip:2.5,2.5 scale:5,5 skew:0,0, srid:12, width:1, height:1', + 12, 1, 1, --- SRID, width, height + 5, 5, 2.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000000440' -- ipX (float64 2.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0C000000' -- SRID (int32 12) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 2, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:0, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 3, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 4, '1x1, ip:7.5,2.5 scale:5,5 skew:1,1, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 1, 1, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'000000000000F03F' -- skewX (float64 1) +|| +'000000000000F03F' -- skewY (float64 1) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 5, '1x1, ip:7.5,2.5 scale:5,5 skew:3,7, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 3, 7, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000001C40' -- skewY (float64 7) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + ----------------------------------------------------------------------- -- st_georeference (default) ----------------------------------------------------------------------- @@ -263,4 +464,4 @@ SELECT FROM rt_properties_test WHERE id = 2; - +DROP TABLE rt_properties_test; diff --git a/raster/test/regress/rt_hasnoband.sql b/raster/test/regress/rt_hasnoband.sql index d2ac4c2c6..eef4d806f 100644 --- a/raster/test/regress/rt_hasnoband.sql +++ b/raster/test/regress/rt_hasnoband.sql @@ -7,7 +7,17 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TABLE empty_raster_test ( + rid numeric, + rast raster +); + +INSERT INTO empty_raster_test +VALUES (1, ST_MakeEmptyRaster( 100, 100, 0.0005, 0.0005, 1, 1, 0, 0, 4326) ); + ------------------------------------------------------------------- -- st_hasnodata ----------------------------------------------------------------------- -select st_hasnoband(rast) from empty_raster_test; \ No newline at end of file +select st_hasnoband(rast) from empty_raster_test; + +DROP TABLE empty_raster_test; diff --git a/raster/test/regress/rt_isempty.sql b/raster/test/regress/rt_isempty.sql index e9ef39a2b..2207628bd 100644 --- a/raster/test/regress/rt_isempty.sql +++ b/raster/test/regress/rt_isempty.sql @@ -7,7 +7,17 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TABLE empty_raster_test ( + rid numeric, + rast raster +); + +INSERT INTO empty_raster_test +VALUES (1, ST_MakeEmptyRaster( 100, 100, 0.0005, 0.0005, 1, 1, 0, 0, 4326) ); + ------------------------------------------------------------------- -- st_isempty ----------------------------------------------------------------------- -select st_isempty(rast) from empty_raster_test; \ No newline at end of file +select st_isempty(rast) from empty_raster_test; + +DROP TABLE empty_raster_test; diff --git a/raster/test/regress/rt_left.sql b/raster/test/regress/rt_left.sql index 7db658e42..53737efd7 100644 --- a/raster/test/regress/rt_left.sql +++ b/raster/test/regress/rt_left.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ------------------------------------------------------------------- -- raster_left ----------------------------------------------------------------------- @@ -36,3 +82,8 @@ SELECT 'X << query(1,1)' as op, FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 AND a.tile << b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_mapalgebraexpr.sql b/raster/test/regress/rt_mapalgebraexpr.sql index 753753a21..97ca7dabc 100644 --- a/raster/test/regress/rt_mapalgebraexpr.sql +++ b/raster/test/regress/rt_mapalgebraexpr.sql @@ -1,3 +1,94 @@ +CREATE OR REPLACE FUNCTION ST_TestRaster(ulx float8, uly float8, val float8) + RETURNS raster AS + $$ + DECLARE + BEGIN + RETURN ST_AddBand(ST_MakeEmptyRaster(10, 10, ulx, uly, 1, 1, 0, 0, 0), '32BF', val, -1); + END; + $$ + LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION raster_plus_twenty(pixel FLOAT, VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + BEGIN + IF pixel IS NULL THEN + RAISE NOTICE 'Pixel value is null.'; + END IF; + RETURN pixel + 20; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + +CREATE OR REPLACE FUNCTION raster_plus_arg1(pixel FLOAT, VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + DECLARE + x float := 0; + BEGIN + IF NOT args[1] IS NULL THEN + x := args[1]::float; + END IF; + RETURN pixel + x; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + +CREATE OR REPLACE FUNCTION raster_polynomial(pixel FLOAT, VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + DECLARE + m float := 1; + b float := 0; + BEGIN + IF NOT args[1] is NULL THEN + m := args[1]::float; + END IF; + IF NOT args[2] is NULL THEN + b := args[2]::float; + END IF; + RETURN m * pixel + b; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + + CREATE OR REPLACE FUNCTION raster_nullage(pixel FLOAT, VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + BEGIN + RETURN NULL; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + + CREATE OR REPLACE FUNCTION raster_x_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + DECLARE + x float := 0; + BEGIN + IF NOT args[1] IS NULL THEN + x := args[1]::float; + END IF; + RETURN pixel + pos[1] + x; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + + CREATE OR REPLACE FUNCTION raster_y_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + DECLARE + x float := 0; + BEGIN + IF NOT args[1] IS NULL THEN + x := args[1]::float; + END IF; + RETURN pixel + pos[2] + x; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + -- Test NULL raster SELECT ST_MapAlgebraExpr(NULL, 1, NULL, '[rast] + 20', 2) IS NULL FROM ST_TestRaster(0, 0, -1) rast; @@ -61,3 +152,11 @@ SELECT 'T12', '32BUI', '[rast.x]' ) AS rast; + +DROP FUNCTION ST_TestRaster(ulx float8, uly float8, val float8); +DROP FUNCTION raster_plus_twenty(pixel FLOAT, VARIADIC args TEXT[]); +DROP FUNCTION raster_plus_arg1(pixel FLOAT, VARIADIC args TEXT[]); +DROP FUNCTION raster_polynomial(pixel FLOAT, VARIADIC args TEXT[]); +DROP FUNCTION raster_nullage(pixel FLOAT, VARIADIC args TEXT[]); +DROP FUNCTION raster_x_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]); +DROP FUNCTION raster_y_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]); diff --git a/raster/test/regress/rt_mapalgebrafct.sql b/raster/test/regress/rt_mapalgebrafct.sql index 77f66bd3e..86d172606 100644 --- a/raster/test/regress/rt_mapalgebrafct.sql +++ b/raster/test/regress/rt_mapalgebrafct.sql @@ -1,3 +1,94 @@ +CREATE OR REPLACE FUNCTION ST_TestRaster(ulx float8, uly float8, val float8) + RETURNS raster AS + $$ + DECLARE + BEGIN + RETURN ST_AddBand(ST_MakeEmptyRaster(10, 10, ulx, uly, 1, 1, 0, 0, 0), '32BF', val, -1); + END; + $$ + LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION raster_plus_twenty(pixel FLOAT, VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + BEGIN + IF pixel IS NULL THEN + RAISE NOTICE 'Pixel value is null.'; + END IF; + RETURN pixel + 20; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + +CREATE OR REPLACE FUNCTION raster_plus_arg1(pixel FLOAT, VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + DECLARE + x float := 0; + BEGIN + IF NOT args[1] IS NULL THEN + x := args[1]::float; + END IF; + RETURN pixel + x; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + +CREATE OR REPLACE FUNCTION raster_polynomial(pixel FLOAT, VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + DECLARE + m float := 1; + b float := 0; + BEGIN + IF NOT args[1] is NULL THEN + m := args[1]::float; + END IF; + IF NOT args[2] is NULL THEN + b := args[2]::float; + END IF; + RETURN m * pixel + b; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + + CREATE OR REPLACE FUNCTION raster_nullage(pixel FLOAT, VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + BEGIN + RETURN NULL; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + + CREATE OR REPLACE FUNCTION raster_x_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + DECLARE + x float := 0; + BEGIN + IF NOT args[1] IS NULL THEN + x := args[1]::float; + END IF; + RETURN pixel + pos[1] + x; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + + CREATE OR REPLACE FUNCTION raster_y_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]) + RETURNS FLOAT AS + $$ + DECLARE + x float := 0; + BEGIN + IF NOT args[1] IS NULL THEN + x := args[1]::float; + END IF; + RETURN pixel + pos[2] + x; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + -- Test NULL raster SELECT ST_MapAlgebraFct(NULL, 1, NULL, 'raster_plus_twenty(float, text[])'::regprocedure) IS NULL FROM ST_TestRaster(0, 0, -1) rast; SELECT ST_MapAlgebraFct(NULL, 1, NULL, 'raster_plus_twenty(float, text[])'::regprocedure, NULL) IS NULL FROM ST_TestRaster(0, 0, -1) rast; @@ -33,3 +124,11 @@ SELECT ST_Value(rast, 1, 1), ST_Value(ST_MapAlgebraFct(rast, 1, NULL, 'raster_nu SELECT ST_Value(rast, 3, 8) + 13 + 3, ST_Value(ST_MapAlgebraFct(rast, 1, NULL, 'raster_x_plus_arg(float, int[], text[])'::regprocedure, '13'), 3, 8) FROM ST_TestRaster(0, 0, 100) AS rast; SELECT ST_Value(rast, 3, 8) + 13 + 8, ST_Value(ST_MapAlgebraFct(rast, 1, NULL, 'raster_y_plus_arg(float, int[], text[])'::regprocedure, '13'), 3, 8) FROM ST_TestRaster(0, 0, 100) AS rast; + +DROP FUNCTION ST_TestRaster(ulx float8, uly float8, val float8); +DROP FUNCTION raster_plus_twenty(pixel FLOAT, VARIADIC args TEXT[]); +DROP FUNCTION raster_plus_arg1(pixel FLOAT, VARIADIC args TEXT[]); +DROP FUNCTION raster_polynomial(pixel FLOAT, VARIADIC args TEXT[]); +DROP FUNCTION raster_nullage(pixel FLOAT, VARIADIC args TEXT[]); +DROP FUNCTION raster_x_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]); +DROP FUNCTION raster_y_plus_arg(pixel FLOAT, pos INT[], VARIADIC args TEXT[]); diff --git a/raster/test/regress/rt_mapalgebrafctngb.sql b/raster/test/regress/rt_mapalgebrafctngb.sql index bafb6acbf..7183a1894 100644 --- a/raster/test/regress/rt_mapalgebrafctngb.sql +++ b/raster/test/regress/rt_mapalgebrafctngb.sql @@ -1,3 +1,29 @@ +-- +-- A user callback function that nullifies all cells in the resulting raster. +-- +CREATE OR REPLACE FUNCTION ST_Nullage(matrix float[][], nodatamode text, VARIADIC args text[]) + RETURNS float AS + $$ + BEGIN + RETURN NULL; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + + +-- +--Test rasters +-- +CREATE OR REPLACE FUNCTION ST_TestRasterNgb(h integer, w integer, val float8) + RETURNS raster AS + $$ + DECLARE + BEGIN + RETURN ST_AddBand(ST_MakeEmptyRaster(h, w, 0, 0, 1, 1, 0, 0, 0), '32BF', val, -1); + END; + $$ + LANGUAGE 'plpgsql'; + -- Tests -- Test NULL Raster. Should be true. SELECT ST_MapAlgebraFctNgb(NULL, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL) IS NULL FROM ST_TestRasterNgb(0, 0, -1) rast; @@ -231,3 +257,6 @@ SELECT ST_MapAlgebraFctNgb(rast, 1, '8BUI', 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, '120', NULL), 2, 2 ) = 200 FROM ST_SetValue(ST_SetBandNoDataValue(ST_TestRasterNgb(3, 3, 10), 0), 2, 2, 0) AS rast; + +DROP FUNCTION ST_Nullage(matrix float[][], nodatamode text, VARIADIC args text[]); +DROP FUNCTION ST_TestRasterNgb(h integer, w integer, val float8); diff --git a/raster/test/regress/rt_mapalgebrafctngb_userfunc.sql b/raster/test/regress/rt_mapalgebrafctngb_userfunc.sql index 3a3aecca9..f78d9a76f 100644 --- a/raster/test/regress/rt_mapalgebrafctngb_userfunc.sql +++ b/raster/test/regress/rt_mapalgebrafctngb_userfunc.sql @@ -1,3 +1,29 @@ +-- +-- A user callback function that nullifies all cells in the resulting raster. +-- +CREATE OR REPLACE FUNCTION ST_Nullage(matrix float[][], nodatamode text, VARIADIC args text[]) + RETURNS float AS + $$ + BEGIN + RETURN NULL; + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + + +-- +--Test rasters +-- +CREATE OR REPLACE FUNCTION ST_TestRasterNgb(h integer, w integer, val float8) + RETURNS raster AS + $$ + DECLARE + BEGIN + RETURN ST_AddBand(ST_MakeEmptyRaster(h, w, 0, 0, 1, 1, 0, 0, 0), '32BF', val, -1); + END; + $$ + LANGUAGE 'plpgsql'; + -- test st_max4ma, uniform values SELECT ST_Value(rast, 2, 2) = 1, @@ -269,3 +295,6 @@ SELECT ), 2, 3, 8 ), 3, 3, 9 ) AS rast; + +DROP FUNCTION ST_Nullage(matrix float[][], nodatamode text, VARIADIC args text[]); +DROP FUNCTION ST_TestRasterNgb(h integer, w integer, val float8); diff --git a/raster/test/regress/rt_overabove.sql b/raster/test/regress/rt_overabove.sql index 9b2284236..317de2236 100644 --- a/raster/test/regress/rt_overabove.sql +++ b/raster/test/regress/rt_overabove.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ------------------------------------------------------------------- -- raster_overabove ----------------------------------------------------------------------- @@ -36,3 +82,8 @@ SELECT 'X |&> query(1,1)' as op, FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 AND a.tile |&> b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_overbelow.sql b/raster/test/regress/rt_overbelow.sql index 6b9a19e76..6a361585f 100644 --- a/raster/test/regress/rt_overbelow.sql +++ b/raster/test/regress/rt_overbelow.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ------------------------------------------------------------------- -- raster_overbelow ----------------------------------------------------------------------- @@ -36,3 +82,9 @@ SELECT 'X &<| query(1,1)' as op, FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 AND a.tile &<| b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; + diff --git a/raster/test/regress/rt_overlap.sql b/raster/test/regress/rt_overlap.sql index cc15b7496..8cf0cee52 100644 --- a/raster/test/regress/rt_overlap.sql +++ b/raster/test/regress/rt_overlap.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ------------------------------------------------------------------- -- raster_overlap ----------------------------------------------------------------------- @@ -95,4 +141,9 @@ SELECT 'X && query(1,1)' as op, st_extent(a.tile::geometry) FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 - AND a.tile::geometry && b.tile; \ No newline at end of file + AND a.tile::geometry && b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_overleft.sql b/raster/test/regress/rt_overleft.sql index f864e979e..8a4c03a0b 100644 --- a/raster/test/regress/rt_overleft.sql +++ b/raster/test/regress/rt_overleft.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ----------------------------------------------------------------------- -- raster_overleft ----------------------------------------------------------------------- @@ -36,3 +82,8 @@ SELECT 'X &< query(1,1)' as op, FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 AND a.tile &< b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_overright.sql b/raster/test/regress/rt_overright.sql index cc089573f..9edce3485 100644 --- a/raster/test/regress/rt_overright.sql +++ b/raster/test/regress/rt_overright.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ----------------------------------------------------------------------- -- raster_overright ----------------------------------------------------------------------- @@ -35,3 +81,8 @@ SELECT 'X &> query(1,1)' as op, FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 AND a.tile &> b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_pixelsize.sql b/raster/test/regress/rt_pixelsize.sql index af49728f4..36c7fd028 100644 --- a/raster/test/regress/rt_pixelsize.sql +++ b/raster/test/regress/rt_pixelsize.sql @@ -7,6 +7,207 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TABLE rt_properties_test ( + id numeric, + name text, + srid integer, + width integer, + height integer, + scalex double precision, + scaley double precision, + ipx double precision, + ipy double precision, + skewx double precision, + skewy double precision, + rast raster +); + +INSERT INTO rt_properties_test +VALUES ( 0, '10x20, ip:0.5,0.5 scale:2,3 skew:0,0 srid:10 width:10 height:20', + 10, 10, 20, --- SRID, width, height + 2, 3, 0.5, 0.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000000040' -- scaleX (float64 2) +|| +'0000000000000840' -- scaleY (float64 3) +|| +'000000000000E03F' -- ipX (float64 0.5) +|| +'000000000000E03F' -- ipY (float64 0.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0A000000' -- SRID (int32 10) +|| +'0A00' -- width (uint16 10) +|| +'1400' -- height (uint16 20) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 1, '1x1, ip:2.5,2.5 scale:5,5 skew:0,0, srid:12, width:1, height:1', + 12, 1, 1, --- SRID, width, height + 5, 5, 2.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000000440' -- ipX (float64 2.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0C000000' -- SRID (int32 12) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 2, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:0, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 3, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 4, '1x1, ip:7.5,2.5 scale:5,5 skew:1,1, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 1, 1, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'000000000000F03F' -- skewX (float64 1) +|| +'000000000000F03F' -- skewY (float64 1) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 5, '1x1, ip:7.5,2.5 scale:5,5 skew:3,7, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 3, 7, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000001C40' -- skewY (float64 7) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + ----------------------------------------------------------------------- -- st_pixelwidth ----------------------------------------------------------------------- @@ -22,3 +223,5 @@ SELECT id, name, scalex, skewy SELECT id, name, scaley, skewx FROM rt_properties_test WHERE NOT sqrt(scaley*scaley + skewx*skewx) = st_pixelheight(rast); + +DROP TABLE rt_properties_test; diff --git a/raster/test/regress/rt_pixelvalue.sql b/raster/test/regress/rt_pixelvalue.sql index f8235081c..aae9c7b35 100644 --- a/raster/test/regress/rt_pixelvalue.sql +++ b/raster/test/regress/rt_pixelvalue.sql @@ -7,6 +7,231 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +----------------------------------------------------------------------- +-- $Id$ +-- +-- Copyright (c) 2009 Pierre Racine +-- +-- This is free software; you can redistribute and/or modify it under +-- the terms of the GNU General Public Licence. See the COPYING file. +----------------------------------------------------------------------- + +----------------------------------------------------------------------- +--- Test of "Get" functions for properties of the raster. +----------------------------------------------------------------------- + +CREATE TABLE rt_band_properties_test ( + id numeric, + description text, + nbband integer, + b1pixeltype text, + b1hasnodatavalue boolean, + b1nodatavalue float4, + b1val float4, + b2pixeltype text, + b2hasnodatavalue boolean, + b2nodatavalue float4, + b2val float4, + geomtxt text, + rast raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 1, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 2, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((782325.5 26744042.5,782330.5 26744045.5,782333.5 26744040.5,782328.5 26744037.5,782325.5 26744042.5))', +( +'01' -- big endian (uint8 xdr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 2) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'00000000000014C0' -- scaleY (float64 -5) +|| +'00000000EBDF2741' -- ipX (float64 782325.5) +|| +'000000A84E817941' -- ipY (float64 26744042.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000000840' -- skewY (float64 3) +|| +'27690000' -- SRID (int32 26919 - UTM 19N) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'4' -- hasnodatavalue set to true +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'02' -- pixel(0,0)==2 +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 2, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 2, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 0) +|| +'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) +|| +'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) +|| +'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) +|| +'718F0E9A27A44840' -- ipY (float64 49.2824585505576) +|| +'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) +|| +'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) +|| +'E6100000' -- SRID (int32 4326) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'4' -- hasnodatavalue set to true +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'02' -- pixel(0,0)==2 +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 3, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 3, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 0) +|| +'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) +|| +'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) +|| +'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) +|| +'718F0E9A27A44840' -- ipY (float64 49.2824585505576) +|| +'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) +|| +'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) +|| +'E6100000' -- SRID (int32 4326) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'6' -- hasnodatavalue and isnodata set to true +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'03' -- pixel(0,0)==3 (same that nodata) +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 4, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 3, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 0) +|| +'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) +|| +'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) +|| +'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) +|| +'718F0E9A27A44840' -- ipY (float64 49.2824585505576) +|| +'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) +|| +'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) +|| +'E6100000' -- SRID (int32 4326) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'4' -- hasnodatavalue set to true and isnodata set to false (should be updated) +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'03' -- pixel(0,0)==3 (same that nodata) +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); + ----------------------------------------------------------------------- -- Test 1 - st_value(rast raster, band integer, x integer, y integer) ----------------------------------------------------------------------- @@ -100,3 +325,4 @@ SELECT 'test 5.1', id FROM rt_band_properties_test WHERE st_value(st_setvalue(rast, 1, st_makepoint(st_upperleftx(rast), st_upperlefty(rast)), 3), 1, 1, 1) != 3; +DROP TABLE rt_band_properties_test; diff --git a/raster/test/regress/rt_right.sql b/raster/test/regress/rt_right.sql index 92166092c..2c1d2bfd1 100644 --- a/raster/test/regress/rt_right.sql +++ b/raster/test/regress/rt_right.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ------------------------------------------------------------------- -- raster_right ----------------------------------------------------------------------- @@ -36,3 +82,8 @@ SELECT 'X >> query(1,1)' as op, FROM rt_gist_grid_test a, rt_gist_query_test b WHERE b.x = 1 and b.y = 1 AND a.tile >> b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_rotation.sql b/raster/test/regress/rt_rotation.sql index e07774ab5..1ce946bda 100644 --- a/raster/test/regress/rt_rotation.sql +++ b/raster/test/regress/rt_rotation.sql @@ -8,6 +8,207 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TABLE rt_properties_test ( + id numeric, + name text, + srid integer, + width integer, + height integer, + scalex double precision, + scaley double precision, + ipx double precision, + ipy double precision, + skewx double precision, + skewy double precision, + rast raster +); + +INSERT INTO rt_properties_test +VALUES ( 0, '10x20, ip:0.5,0.5 scale:2,3 skew:0,0 srid:10 width:10 height:20', + 10, 10, 20, --- SRID, width, height + 2, 3, 0.5, 0.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000000040' -- scaleX (float64 2) +|| +'0000000000000840' -- scaleY (float64 3) +|| +'000000000000E03F' -- ipX (float64 0.5) +|| +'000000000000E03F' -- ipY (float64 0.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0A000000' -- SRID (int32 10) +|| +'0A00' -- width (uint16 10) +|| +'1400' -- height (uint16 20) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 1, '1x1, ip:2.5,2.5 scale:5,5 skew:0,0, srid:12, width:1, height:1', + 12, 1, 1, --- SRID, width, height + 5, 5, 2.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000000440' -- ipX (float64 2.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0C000000' -- SRID (int32 12) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 2, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:0, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 3, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 4, '1x1, ip:7.5,2.5 scale:5,5 skew:1,1, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 1, 1, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'000000000000F03F' -- skewX (float64 1) +|| +'000000000000F03F' -- skewY (float64 1) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 5, '1x1, ip:7.5,2.5 scale:5,5 skew:3,7, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 3, 7, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000001C40' -- skewY (float64 7) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + ----------------------------------------------------------------------- -- st_skewx ----------------------------------------------------------------------- @@ -89,3 +290,5 @@ SELECT 'T6', id, scalex, scaley, skewx, skewy, DELETE FROM rt_properties_test WHERE id > 100; + +DROP TABLE rt_properties_test; diff --git a/raster/test/regress/rt_same.sql b/raster/test/regress/rt_same.sql index e9147982c..abe8455eb 100644 --- a/raster/test/regress/rt_same.sql +++ b/raster/test/regress/rt_same.sql @@ -7,6 +7,52 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TYPE tile AS (x int, y int, tile raster); +CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int) + RETURNS SETOF tile +AS +' +DECLARE + gridCols alias for $1; + gridRows alias for $2; + extent alias for $3; + tileWidth alias for $4; + tileHeight alias for $5; + rec tile; + scalex float8; + scaley float8; + ipx float8; + ipy float8; +BEGIN + + -- compute some sizes + -- each tile extent width is extent.width / gridRows + scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth; + scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight; + + FOR y IN 0..gridRows-1 LOOP + ipy = y*scaley + ST_ymin(extent); + FOR x IN 0..gridCols-1 LOOP + ipx = x*scalex + ST_xmin(extent); + rec.x = x; + rec.y = y; + rec.tile = st_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy, + scalex, scaley, 0, 0); + RETURN NEXT rec; + END LOOP; + END LOOP; + + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE TABLE rt_gist_grid_test AS + SELECT * FROM makegrid(10, 10, 'BOX(-100 -100, 100 100)', 1, 1); + +CREATE TABLE rt_gist_query_test AS + SELECT * from makegrid(3, 3, 'BOX(-100 -100, 100 100)', 1, 1); + ------------------------------------------------------------------- -- raster_same ----------------------------------------------------------------------- @@ -58,3 +104,8 @@ SELECT 'X ~= tile(7,7)' as op, FROM rt_gist_grid_test a, rt_gist_grid_test b WHERE b.x = 7 and b.y = 7 AND a.tile ~= b.tile; + +DROP FUNCTION makegrid(integer,integer,box2d,integer,integer); +DROP table rt_gist_grid_test; +DROP table rt_gist_query_test; +DROP type tile; diff --git a/raster/test/regress/rt_scale.sql b/raster/test/regress/rt_scale.sql index b5a9c4299..186dbccf7 100644 --- a/raster/test/regress/rt_scale.sql +++ b/raster/test/regress/rt_scale.sql @@ -7,6 +7,207 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TABLE rt_properties_test ( + id numeric, + name text, + srid integer, + width integer, + height integer, + scalex double precision, + scaley double precision, + ipx double precision, + ipy double precision, + skewx double precision, + skewy double precision, + rast raster +); + +INSERT INTO rt_properties_test +VALUES ( 0, '10x20, ip:0.5,0.5 scale:2,3 skew:0,0 srid:10 width:10 height:20', + 10, 10, 20, --- SRID, width, height + 2, 3, 0.5, 0.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000000040' -- scaleX (float64 2) +|| +'0000000000000840' -- scaleY (float64 3) +|| +'000000000000E03F' -- ipX (float64 0.5) +|| +'000000000000E03F' -- ipY (float64 0.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0A000000' -- SRID (int32 10) +|| +'0A00' -- width (uint16 10) +|| +'1400' -- height (uint16 20) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 1, '1x1, ip:2.5,2.5 scale:5,5 skew:0,0, srid:12, width:1, height:1', + 12, 1, 1, --- SRID, width, height + 5, 5, 2.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000000440' -- ipX (float64 2.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0C000000' -- SRID (int32 12) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 2, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:0, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 3, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 4, '1x1, ip:7.5,2.5 scale:5,5 skew:1,1, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 1, 1, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'000000000000F03F' -- skewX (float64 1) +|| +'000000000000F03F' -- skewY (float64 1) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 5, '1x1, ip:7.5,2.5 scale:5,5 skew:3,7, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 3, 7, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000001C40' -- skewY (float64 7) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + ----------------------------------------------------------------------- -- st_scalex ----------------------------------------------------------------------- @@ -22,3 +223,5 @@ SELECT id, name, scalex SELECT id, name, scaley FROM rt_properties_test WHERE st_scaley(rast) != scaley; + +DROP TABLE rt_properties_test; diff --git a/raster/test/regress/rt_set_band_properties.sql b/raster/test/regress/rt_set_band_properties.sql index fe6fa0684..d8056340d 100644 --- a/raster/test/regress/rt_set_band_properties.sql +++ b/raster/test/regress/rt_set_band_properties.sql @@ -11,6 +11,230 @@ --- Test of "Set" functions for properties of a raster band. ----------------------------------------------------------------------- +----------------------------------------------------------------------- +-- $Id$ +-- +-- Copyright (c) 2009 Pierre Racine +-- +-- This is free software; you can redistribute and/or modify it under +-- the terms of the GNU General Public Licence. See the COPYING file. +----------------------------------------------------------------------- + +----------------------------------------------------------------------- +--- Test of "Get" functions for properties of the raster. +----------------------------------------------------------------------- + +CREATE TABLE rt_band_properties_test ( + id numeric, + description text, + nbband integer, + b1pixeltype text, + b1hasnodatavalue boolean, + b1nodatavalue float4, + b1val float4, + b2pixeltype text, + b2hasnodatavalue boolean, + b2nodatavalue float4, + b2val float4, + geomtxt text, + rast raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 1, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 2, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((782325.5 26744042.5,782330.5 26744045.5,782333.5 26744040.5,782328.5 26744037.5,782325.5 26744042.5))', +( +'01' -- big endian (uint8 xdr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 2) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'00000000000014C0' -- scaleY (float64 -5) +|| +'00000000EBDF2741' -- ipX (float64 782325.5) +|| +'000000A84E817941' -- ipY (float64 26744042.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000000840' -- skewY (float64 3) +|| +'27690000' -- SRID (int32 26919 - UTM 19N) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'4' -- hasnodatavalue set to true +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'02' -- pixel(0,0)==2 +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 2, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 2, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 0) +|| +'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) +|| +'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) +|| +'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) +|| +'718F0E9A27A44840' -- ipY (float64 49.2824585505576) +|| +'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) +|| +'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) +|| +'E6100000' -- SRID (int32 4326) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'4' -- hasnodatavalue set to true +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'02' -- pixel(0,0)==2 +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 3, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 3, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 0) +|| +'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) +|| +'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) +|| +'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) +|| +'718F0E9A27A44840' -- ipY (float64 49.2824585505576) +|| +'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) +|| +'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) +|| +'E6100000' -- SRID (int32 4326) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'6' -- hasnodatavalue and isnodata set to true +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'03' -- pixel(0,0)==3 (same that nodata) +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); + +INSERT INTO rt_band_properties_test +VALUES ( 4, '1x1, nbband:2 b1pixeltype:4BUI b1hasnodatavalue:true b1nodatavalue:3 b2pixeltype:16BSI b2hasnodatavalue:false b2nodatavalue:13', + 2, --- nbband + '4BUI', true, 3, 3, --- b1pixeltype, b1hasnodatavalue, b1nodatavalue, b1val + '16BSI', false, 13, 4, --- b2pixeltype, b2hasnodatavalue, b2nodatavalue, b2val + 'POLYGON((-75.5533328537098 49.2824585505576,-75.5525268884758 49.2826703629415,-75.5523150760919 49.2818643977075,-75.553121041326 49.2816525853236,-75.5533328537098 49.2824585505576))', +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0200' -- nBands (uint16 0) +|| +'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) +|| +'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) +|| +'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) +|| +'718F0E9A27A44840' -- ipY (float64 49.2824585505576) +|| +'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) +|| +'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) +|| +'E6100000' -- SRID (int32 4326) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +|| +'4' -- hasnodatavalue set to true and isnodata set to false (should be updated) +|| +'2' -- first band type (4BUI) +|| +'03' -- novalue==3 +|| +'03' -- pixel(0,0)==3 (same that nodata) +|| +'0' -- hasnodatavalue set to false +|| +'5' -- second band type (16BSI) +|| +'0D00' -- novalue==13 +|| +'0400' -- pixel(0,0)==4 +)::raster +); ----------------------------------------------------------------------- --- ST_SetBandNoDataValue @@ -21,3 +245,5 @@ SELECT st_bandnodatavalue(st_setbandnodatavalue(rast, 1, b1nodatavalue+1),1) AS obtained FROM rt_band_properties_test WHERE (b1nodatavalue+1) != st_bandnodatavalue(st_setbandnodatavalue(rast, 1, b1nodatavalue+1),1); + +DROP TABLE rt_band_properties_test; diff --git a/raster/test/regress/rt_set_properties.sql b/raster/test/regress/rt_set_properties.sql index 951a84f92..03b058ebd 100644 --- a/raster/test/regress/rt_set_properties.sql +++ b/raster/test/regress/rt_set_properties.sql @@ -7,6 +7,207 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TABLE rt_properties_test ( + id numeric, + name text, + srid integer, + width integer, + height integer, + scalex double precision, + scaley double precision, + ipx double precision, + ipy double precision, + skewx double precision, + skewy double precision, + rast raster +); + +INSERT INTO rt_properties_test +VALUES ( 0, '10x20, ip:0.5,0.5 scale:2,3 skew:0,0 srid:10 width:10 height:20', + 10, 10, 20, --- SRID, width, height + 2, 3, 0.5, 0.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000000040' -- scaleX (float64 2) +|| +'0000000000000840' -- scaleY (float64 3) +|| +'000000000000E03F' -- ipX (float64 0.5) +|| +'000000000000E03F' -- ipY (float64 0.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0A000000' -- SRID (int32 10) +|| +'0A00' -- width (uint16 10) +|| +'1400' -- height (uint16 20) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 1, '1x1, ip:2.5,2.5 scale:5,5 skew:0,0, srid:12, width:1, height:1', + 12, 1, 1, --- SRID, width, height + 5, 5, 2.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000000440' -- ipX (float64 2.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0C000000' -- SRID (int32 12) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 2, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:0, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 3, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 4, '1x1, ip:7.5,2.5 scale:5,5 skew:1,1, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 1, 1, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'000000000000F03F' -- skewX (float64 1) +|| +'000000000000F03F' -- skewY (float64 1) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 5, '1x1, ip:7.5,2.5 scale:5,5 skew:3,7, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 3, 7, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000001C40' -- skewY (float64 7) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + ----------------------------------------------------------------------- --- Test of "Set" functions for properties of the raster. --- (Objective B03a) @@ -86,3 +287,5 @@ SELECT WHERE (ipx+2) != st_upperleftx(st_setupperleft(rast,ipx+2,ipy)) OR (ipy+3) != st_upperlefty(st_setupperleft(rast,ipx,ipy+3)); + +DROP TABLE rt_properties_test; diff --git a/raster/test/regress/rt_upperleft.sql b/raster/test/regress/rt_upperleft.sql index 931af757e..eedaa0883 100644 --- a/raster/test/regress/rt_upperleft.sql +++ b/raster/test/regress/rt_upperleft.sql @@ -7,6 +7,207 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- +CREATE TABLE rt_properties_test ( + id numeric, + name text, + srid integer, + width integer, + height integer, + scalex double precision, + scaley double precision, + ipx double precision, + ipy double precision, + skewx double precision, + skewy double precision, + rast raster +); + +INSERT INTO rt_properties_test +VALUES ( 0, '10x20, ip:0.5,0.5 scale:2,3 skew:0,0 srid:10 width:10 height:20', + 10, 10, 20, --- SRID, width, height + 2, 3, 0.5, 0.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000000040' -- scaleX (float64 2) +|| +'0000000000000840' -- scaleY (float64 3) +|| +'000000000000E03F' -- ipX (float64 0.5) +|| +'000000000000E03F' -- ipY (float64 0.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0A000000' -- SRID (int32 10) +|| +'0A00' -- width (uint16 10) +|| +'1400' -- height (uint16 20) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 1, '1x1, ip:2.5,2.5 scale:5,5 skew:0,0, srid:12, width:1, height:1', + 12, 1, 1, --- SRID, width, height + 5, 5, 2.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000000440' -- ipX (float64 2.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'0C000000' -- SRID (int32 12) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 2, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:0, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 3, '1x1, ip:7.5,2.5 scale:5,5 skew:0,0, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 4, '1x1, ip:7.5,2.5 scale:5,5 skew:1,1, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 1, 1, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'000000000000F03F' -- skewX (float64 1) +|| +'000000000000F03F' -- skewY (float64 1) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + +INSERT INTO rt_properties_test +VALUES ( 5, '1x1, ip:7.5,2.5 scale:5,5 skew:3,7, srid:-1, width:1, height:1', + 0, 1, 1, --- SRID, width, height + 5, 5, 7.5, 2.5, 3, 7, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'0000000000001440' -- scaleY (float64 5) +|| +'0000000000001E40' -- ipX (float64 7.5) +|| +'0000000000000440' -- ipY (float64 2.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000001C40' -- skewY (float64 7) +|| +'00000000' -- SRID (int32 0) +|| +'0100' -- width (uint16 1) +|| +'0100' -- height (uint16 1) +)::raster +); + ----------------------------------------------------------------------- -- st_upperleftx ----------------------------------------------------------------------- @@ -22,3 +223,5 @@ SELECT id, name, ipx, st_upperleftx(rast) as ipx_expected SELECT id, name, ipy, st_upperlefty(rast) as ipy_expected FROM rt_properties_test WHERE st_upperlefty(rast) != ipy; + +DROP TABLE rt_properties_test; diff --git a/raster/test/regress/rt_utility.sql b/raster/test/regress/rt_utility.sql index 1ec176985..2b5142f8f 100644 --- a/raster/test/regress/rt_utility.sql +++ b/raster/test/regress/rt_utility.sql @@ -7,7 +7,144 @@ -- the terms of the GNU General Public Licence. See the COPYING file. ----------------------------------------------------------------------- -\i create_rt_utility_test.sql +CREATE TABLE rt_utility_test ( + id numeric, + name text, + srid integer, + width integer, + height integer, + scalex double precision, + scaley double precision, + ipx double precision, + ipy double precision, + skewx double precision, + skewy double precision, + rast raster +); + +INSERT INTO rt_utility_test +VALUES ( 1, '1217x1156, ip:782325.5,26744042.5 scale:5,-5 skew:0,0 srid:9102707 width:1217 height:1156', + 26919, 1217, 1156, --- SRID, width, height + 5, -5, 782325.5, 26744042.5, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'00000000000014C0' -- scaleY (float64 -5) +|| +'00000000EBDF2741' -- ipX (float64 782325.5) +|| +'000000A84E817941' -- ipY (float64 26744042.5) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'27690000' -- SRID (int32 26919 - UTM 19N) +|| +'C104' -- width (uint16 1217) +|| +'8404' -- height (uint16 1156) +)::raster +); + +INSERT INTO rt_utility_test +VALUES ( 2, '1217x1156, ip:782325.5,26744042.5 scale:5,-5 skew:3,3 srid:9102707 width:1217 height:1156', + 26919, 1217, 1156, --- SRID, width, height + 5, -5, 782325.5, 26744042.5, 3, 3, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'0000000000001440' -- scaleX (float64 5) +|| +'00000000000014C0' -- scaleY (float64 -5) +|| +'00000000EBDF2741' -- ipX (float64 782325.5) +|| +'000000A84E817941' -- ipY (float64 26744042.5) +|| +'0000000000000840' -- skewX (float64 3) +|| +'0000000000000840' -- skewY (float64 3) +|| +'27690000' -- SRID (int32 26919 - UTM 19N) +|| +'C104' -- width (uint16 1217) +|| +'8404' -- height (uint16 1156) +)::raster +); + +INSERT INTO rt_utility_test +VALUES ( 3, '6000x6000, ip:-75,50 scale:0.000833333333333333,-0.000833333333333333 skew:0,0 srid:4326 width:6000 height:6000', + 4326, 6000, 6000, --- SRID, width, height + 0.000833333333333333, -0.000833333333333333, -75, 50, 0, 0, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'4F1BE8B4814E4B3F' -- scaleX (float64 0.000833333333333333) +|| +'4F1BE8B4814E4BBF' -- scaleY (float64 -0.000833333333333333) +|| +'0000000000C052C0' -- ipX (float64 -75) +|| +'0000000000004940' -- ipY (float64 50) +|| +'0000000000000000' -- skewX (float64 0) +|| +'0000000000000000' -- skewY (float64 0) +|| +'E6100000' -- SRID (int32 4326) +|| +'7017' -- width (uint16 6000) +|| +'7017' -- height (uint16 6000) +)::raster +); + +INSERT INTO rt_utility_test +VALUES ( 4, '6000x6000, ip:-75.5533328537098,49.2824585505576 scale:0.000805965234044584,-0.00080596523404458 skew:0.000211812383858707,0.000211812383858704 srid:4326 width:6000 height:6000', + 4326, 6000, 6000, --- SRID, width, height + 0.000805965234044584, -0.00080596523404458, -75.5533328537098, 49.2824585505576, 0.000211812383858707, 0.000211812383858704, --- georeference +( +'01' -- little endian (uint8 ndr) +|| +'0000' -- version (uint16 0) +|| +'0000' -- nBands (uint16 0) +|| +'17263529ED684A3F' -- scaleX (float64 0.000805965234044584) +|| +'F9253529ED684ABF' -- scaleY (float64 -0.00080596523404458) +|| +'1C9F33CE69E352C0' -- ipX (float64 -75.5533328537098) +|| +'718F0E9A27A44840' -- ipY (float64 49.2824585505576) +|| +'ED50EB853EC32B3F' -- skewX (float64 0.000211812383858707) +|| +'7550EB853EC32B3F' -- skewY (float64 0.000211812383858704) +|| +'E6100000' -- SRID (int32 4326) +|| +'7017' -- width (uint16 6000) +|| +'7017' -- height (uint16 6000) +)::raster +); ----------------------------------------------------------------------- -- Test 1 - st_world2rastercoordx(rast raster, xw float8, yw float8)