rt_aspng
TEST_PROPS = \
- create_rt_properties_test \
rt_dimensions \
rt_scale \
rt_pixelsize \
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 \
rt_valuepercent \
rt_bandmetadata \
rt_pixelvalue \
- drop_rt_band_properties_test \
rt_neighborhood \
rt_nearestvalue \
rt_pixelofvalue \
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 \
rt_union
TEST_GIST = \
- create_rt_gist_test \
rt_above \
rt_below \
rt_contained \
rt_overleft \
rt_overright \
rt_right \
- rt_same \
- drop_rt_gist_test
-
+ rt_same
+
TEST_SREL = \
rt_intersects \
rt_overlaps \
+++ /dev/null
------------------------------------------------------------------------
--- $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
-);
-
+++ /dev/null
------------------------------------------------------------------------
--- $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
+++ /dev/null
------------------------------------------------------------------------
--- $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);
+++ /dev/null
-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;
+++ /dev/null
---
--- 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';
+++ /dev/null
------------------------------------------------------------------------
--- $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
-);
+++ /dev/null
------------------------------------------------------------------------
--- $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
-);
+++ /dev/null
-DROP TABLE rt_band_properties_test;
+++ /dev/null
-DROP TABLE empty_raster_test;
+++ /dev/null
-DROP FUNCTION makegrid(integer,integer,box2d,integer,integer);
-DROP table rt_gist_grid_test;
-DROP table rt_gist_query_test;
-DROP type tile;
-
+++ /dev/null
-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[]);
+++ /dev/null
-DROP FUNCTION ST_Nullage(matrix float[][], nodatamode text, VARIADIC args text[]);
-DROP FUNCTION ST_TestRasterNgb(h integer, w integer, val float8);
+++ /dev/null
-DROP TABLE rt_properties_test;
-
-- 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
-----------------------------------------------------------------------
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;
--- 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
FROM rt_band_properties_test
WHERE id = 4;
+DROP TABLE rt_band_properties_test;
-- 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
-----------------------------------------------------------------------
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;
-- 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
-----------------------------------------------------------------------
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;
-- 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
-----------------------------------------------------------------------
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;
-- 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
-----------------------------------------------------------------------
SELECT id, name, height
FROM rt_properties_test
WHERE st_height(rast) != height;
+
+DROP TABLE rt_properties_test;
-- 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)
-----------------------------------------------------------------------
FROM rt_properties_test
WHERE id = 2;
-
+DROP TABLE rt_properties_test;
-- 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;
-- 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;
-- 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
-----------------------------------------------------------------------
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;
+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;
'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[]);
+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;
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[]);
+--
+-- 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;
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);
+--
+-- 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,
), 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);
-- 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
-----------------------------------------------------------------------
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;
-- 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
-----------------------------------------------------------------------
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;
+
-- 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
-----------------------------------------------------------------------
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;
-- 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
-----------------------------------------------------------------------
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;
-- 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
-----------------------------------------------------------------------
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;
-- 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
-----------------------------------------------------------------------
SELECT id, name, scaley, skewx
FROM rt_properties_test
WHERE NOT sqrt(scaley*scaley + skewx*skewx) = st_pixelheight(rast);
+
+DROP TABLE rt_properties_test;
-- 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)
-----------------------------------------------------------------------
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;
-- 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
-----------------------------------------------------------------------
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;
-- 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
-----------------------------------------------------------------------
DELETE FROM rt_properties_test
WHERE id > 100;
+
+DROP TABLE rt_properties_test;
-- 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
-----------------------------------------------------------------------
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;
-- 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
-----------------------------------------------------------------------
SELECT id, name, scaley
FROM rt_properties_test
WHERE st_scaley(rast) != scaley;
+
+DROP TABLE rt_properties_test;
--- 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
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;
-- 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)
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;
-- 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
-----------------------------------------------------------------------
SELECT id, name, ipy, st_upperlefty(rast) as ipy_expected
FROM rt_properties_test
WHERE st_upperlefty(rast) != ipy;
+
+DROP TABLE rt_properties_test;
-- 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)