]> granicus.if.org Git - postgis/commitdiff
Consolidated create_* and drop_* scripts into respective regression
authorBborie Park <bkpark at ucdavis.edu>
Wed, 25 Jul 2012 03:36:24 +0000 (03:36 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Wed, 25 Jul 2012 03:36:24 +0000 (03:36 +0000)
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

55 files changed:
raster/test/regress/Makefile.in
raster/test/regress/create_rt_band_properties_test.sql [deleted file]
raster/test/regress/create_rt_band_properties_test_expected [deleted file]
raster/test/regress/create_rt_empty_raster_test.sql [deleted file]
raster/test/regress/create_rt_empty_raster_test_expected [deleted file]
raster/test/regress/create_rt_gist_test.sql [deleted file]
raster/test/regress/create_rt_gist_test_expected [deleted file]
raster/test/regress/create_rt_mapalgebra_test.sql [deleted file]
raster/test/regress/create_rt_mapalgebra_test_expected [deleted file]
raster/test/regress/create_rt_mapalgebrafctngb_test.sql [deleted file]
raster/test/regress/create_rt_mapalgebrafctngb_test_expected [deleted file]
raster/test/regress/create_rt_properties_test.sql [deleted file]
raster/test/regress/create_rt_properties_test_expected [deleted file]
raster/test/regress/create_rt_utility_test.sql [deleted file]
raster/test/regress/drop_rt_band_properties_test.sql [deleted file]
raster/test/regress/drop_rt_band_properties_test_expected [deleted file]
raster/test/regress/drop_rt_empty_raster_test.sql [deleted file]
raster/test/regress/drop_rt_empty_raster_test_expected [deleted file]
raster/test/regress/drop_rt_gist_test.sql [deleted file]
raster/test/regress/drop_rt_gist_test_expected [deleted file]
raster/test/regress/drop_rt_mapalgebra_test.sql [deleted file]
raster/test/regress/drop_rt_mapalgebra_test_expected [deleted file]
raster/test/regress/drop_rt_mapalgebrafctngb_test.sql [deleted file]
raster/test/regress/drop_rt_mapalgebrafctngb_test_expected [deleted file]
raster/test/regress/drop_rt_properties_test.sql [deleted file]
raster/test/regress/drop_rt_properties_test_expected [deleted file]
raster/test/regress/rt_above.sql
raster/test/regress/rt_band_properties.sql
raster/test/regress/rt_below.sql
raster/test/regress/rt_contain.sql
raster/test/regress/rt_contained.sql
raster/test/regress/rt_dimensions.sql
raster/test/regress/rt_georeference.sql
raster/test/regress/rt_hasnoband.sql
raster/test/regress/rt_isempty.sql
raster/test/regress/rt_left.sql
raster/test/regress/rt_mapalgebraexpr.sql
raster/test/regress/rt_mapalgebrafct.sql
raster/test/regress/rt_mapalgebrafctngb.sql
raster/test/regress/rt_mapalgebrafctngb_userfunc.sql
raster/test/regress/rt_overabove.sql
raster/test/regress/rt_overbelow.sql
raster/test/regress/rt_overlap.sql
raster/test/regress/rt_overleft.sql
raster/test/regress/rt_overright.sql
raster/test/regress/rt_pixelsize.sql
raster/test/regress/rt_pixelvalue.sql
raster/test/regress/rt_right.sql
raster/test/regress/rt_rotation.sql
raster/test/regress/rt_same.sql
raster/test/regress/rt_scale.sql
raster/test/regress/rt_set_band_properties.sql
raster/test/regress/rt_set_properties.sql
raster/test/regress/rt_upperleft.sql
raster/test/regress/rt_utility.sql

index 779b1aec86ed5eb87f19879875972eccf013456b..6319418722351771b468cfa2f6764331907a0cb9 100644 (file)
@@ -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 (file)
index fd75668..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
------------------------------------------------------------------------
--- $Id$
---
--- Copyright (c) 2009 Pierre Racine <pierre.racine@sbf.ulaval.ca>
---
--- 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 (file)
index e69de29..0000000
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 (file)
index e60a0a9..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
------------------------------------------------------------------------
--- $Id$
---
--- Copyright (c) 2011 Jorge Arevalo <jorge.arevalo@deimos-space.com>
---
--- 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 (file)
index e69de29..0000000
diff --git a/raster/test/regress/create_rt_gist_test.sql b/raster/test/regress/create_rt_gist_test.sql
deleted file mode 100644 (file)
index a835620..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
------------------------------------------------------------------------
--- $Id$
---
--- Copyright (c) 2009 Sandro Santilli <strk@keybit.net>
---
--- 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( <gridColumns>, <gridRows>, <gridExtent>,
---               <tileWidth>, <tileHeight> )
---
--- 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 (file)
index e69de29..0000000
diff --git a/raster/test/regress/create_rt_mapalgebra_test.sql b/raster/test/regress/create_rt_mapalgebra_test.sql
deleted file mode 100644 (file)
index b517582..0000000
+++ /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 (file)
index e69de29..0000000
diff --git a/raster/test/regress/create_rt_mapalgebrafctngb_test.sql b/raster/test/regress/create_rt_mapalgebrafctngb_test.sql
deleted file mode 100644 (file)
index f4ac7e4..0000000
+++ /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 (file)
index e69de29..0000000
diff --git a/raster/test/regress/create_rt_properties_test.sql b/raster/test/regress/create_rt_properties_test.sql
deleted file mode 100644 (file)
index b1ec268..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
------------------------------------------------------------------------
--- $Id$
---
--- Copyright (c) 2009 Mateusz Loskot <mateusz@loskot.net>
---
--- 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 (file)
index e69de29..0000000
diff --git a/raster/test/regress/create_rt_utility_test.sql b/raster/test/regress/create_rt_utility_test.sql
deleted file mode 100644 (file)
index b0bf900..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
------------------------------------------------------------------------
--- $Id$
---
--- Copyright (c) 2009 Pierre Racine <pierre.racine@sbf.ulaval.ca>
---
--- 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 (file)
index 455753b..0000000
+++ /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 (file)
index e69de29..0000000
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 (file)
index 555bf44..0000000
+++ /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 (file)
index e69de29..0000000
diff --git a/raster/test/regress/drop_rt_gist_test.sql b/raster/test/regress/drop_rt_gist_test.sql
deleted file mode 100644 (file)
index 65fc391..0000000
+++ /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 (file)
index e69de29..0000000
diff --git a/raster/test/regress/drop_rt_mapalgebra_test.sql b/raster/test/regress/drop_rt_mapalgebra_test.sql
deleted file mode 100644 (file)
index 245ee34..0000000
+++ /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 (file)
index e69de29..0000000
diff --git a/raster/test/regress/drop_rt_mapalgebrafctngb_test.sql b/raster/test/regress/drop_rt_mapalgebrafctngb_test.sql
deleted file mode 100644 (file)
index 391ee2e..0000000
+++ /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 (file)
index e69de29..0000000
diff --git a/raster/test/regress/drop_rt_properties_test.sql b/raster/test/regress/drop_rt_properties_test.sql
deleted file mode 100644 (file)
index 537cdbb..0000000
+++ /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 (file)
index e69de29..0000000
index 8c395fea206cde8d6b29155253e1f48a6db441b8..ad264623da97ebb67e032be4c17836c8e9d6d7f2 100644 (file)
@@ -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;
index a42519f07bb5e06a4defb5d3659d076a1a7748de..80bbe22b39f01ec7ee6d90bc936c42828762131e 100644 (file)
 --- 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;
index 46adc50142c7b36b577b58aed84965f4b58009d1..c64f43c22060860b19048f7fac39a115d402b9bd 100644 (file)
@@ -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;
index d9a3755cb51ecb208fd75f5a11908ed836e73300..db7eb76c6ac9267340505c8784a819764951a90b 100644 (file)
@@ -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;
index 052947fba6f080b9f89ab8e41d9d129fb53acb93..9a282f034110434621c9e1f58399413f8d551a78 100644 (file)
@@ -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;
index 6dc4eb68910b21413cca72f9e5e32bad28d67b65..878b72a8ef4222dabc150da382f23523c6864c98 100644 (file)
@@ -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;
index 845593910a0b87efebdb1592f92853b1fd753ed9..98b18297f4fd2a3e2b03e1a4f2226e01d8040563 100644 (file)
@@ -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;
index d2ac4c2c6e3628c4e0d3280855aa4598b90abfeb..eef4d806f4e49bd2802635e603386e95dde39683 100644 (file)
@@ -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;
index e9ef39a2b357c0c283d46c9c8f173506abd00325..2207628bd719d5d511d934af03386ab2d7074542 100644 (file)
@@ -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;
index 7db658e427f9c8f242e9f9eafc964ea0bb94c21c..53737efd730c1a605c8aca05dc05a64999a7a094 100644 (file)
@@ -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;
index 753753a2122a4ead4e24bf6cf665b1f981354a2f..97ca7dabcabb85bcdd92b1fba30602b5fea213db 100644 (file)
@@ -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[]);
index 77f66bd3e5a2b984066059889997aa405b356728..86d1726060a5cf3d5007a84954806bc8c53e35ef 100644 (file)
@@ -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[]);
index bafb6acbfd6047e56f07328158080c3a40556856..7183a1894c635ce728e665fedbb57d78a86b3c0f 100644 (file)
@@ -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);
index 3a3aecca9e368f60f8815715e0c9378d57346f71..f78d9a76f186c93097b70ab54b71f4f234e9ff84 100644 (file)
@@ -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);
index 9b2284236aa073c0f1ef9d79e6f3f42495926685..317de2236029bc9d225ef25c160760d9a41bd9c5 100644 (file)
@@ -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;
index 6b9a19e7604b97686017eaa9cc1e7bef9f6ecfcc..6a361585fb53cb6addb68bf7d39787af55f49760 100644 (file)
@@ -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;
+
index cc15b7496267ea6ea4c408c9e5b869b1d57369ef..8cf0cee5239d3172b03cb8b4b04ff8a9f7042ffa 100644 (file)
@@ -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;
index f864e979ea5c1c1da82efc660a74cb1624172a00..8a4c03a0b95fe80e5c9361a452bb0fcbefd16b58 100644 (file)
@@ -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;
index cc089573fd87307e170703e06ef71b1d1556377f..9edce3485bafee346052943b3b787f9ec87a2271 100644 (file)
@@ -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;
index af49728f435621325764549679a7156c3598d2b1..36c7fd028e918122da09f68672d95e02d4a52008 100644 (file)
@@ -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;
index f8235081c8750139619d7a8b2376440ba61eaad1..aae9c7b35b6f368a349112ea5cd5d20eb3886fb9 100644 (file)
@@ -7,6 +7,231 @@
 -- the terms of the GNU General Public Licence. See the COPYING file.
 -----------------------------------------------------------------------
 
+-----------------------------------------------------------------------
+-- $Id$
+--
+-- Copyright (c) 2009 Pierre Racine <pierre.racine@sbf.ulaval.ca>
+--
+-- 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;
index 92166092c161366bef25242b8d2176e69388a377..2c1d2bfd1c72e27c9822c66619d6a71bad032140 100644 (file)
@@ -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;
index e07774ab591f35d705bc16ee37afee9176b1bfa9..1ce946bda152d35f99828eb01e444bc9f0a69418 100644 (file)
@@ -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;
index e9147982c5f2e8a6a94f143b1a812a31b3d767bb..abe8455eb57aafb2a7ea040038e18274a54e3265 100644 (file)
@@ -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;
index b5a9c4299040c7798081f281e031e91a3f9380a7..186dbccf7d9b436f1285691e44da3810133330e2 100644 (file)
@@ -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;
index fe6fa0684e9780e6e55441e6c371c31285934b2d..d8056340db64776c27208b5766d041f97f185806 100644 (file)
 --- Test of "Set" functions for properties of a raster band.
 -----------------------------------------------------------------------
 
+-----------------------------------------------------------------------
+-- $Id$
+--
+-- Copyright (c) 2009 Pierre Racine <pierre.racine@sbf.ulaval.ca>
+--
+-- 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;
index 951a84f925741f0b7963dd6b6fd192e33f1db5f3..03b058ebd6460a3a583a6d79be0e8f40efcadd32 100644 (file)
@@ -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;
index 931af757eb2f24c9a4571a262d8d647b60847524..eedaa08833a330731c912e8526e1b404fd3b62c6 100644 (file)
@@ -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;
index 1ec1769852ffbf90c9dde3700adf56b987bfbb96..2b5142f8fc961fb2835d6155366c69aaa862092d 100644 (file)
@@ -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)