Commit 433e5f08 authored by Bborie Park's avatar Bborie Park

Consolidated create_* and drop_* scripts into respective regression

tests.  Should make things easier to build a valgrind test suite.

git-svn-id: http://svn.osgeo.org/postgis/trunk@10117 b70326c6-7e19-0410-871a-916f4a2858ee
parent 3dbe5cbd
......@@ -50,7 +50,6 @@ TEST_FUNC = \
rt_aspng
TEST_PROPS = \
create_rt_properties_test \
rt_dimensions \
rt_scale \
rt_pixelsize \
......@@ -58,17 +57,13 @@ TEST_PROPS = \
rt_rotation \
rt_georeference \
rt_set_properties \
drop_rt_properties_test \
create_rt_empty_raster_test \
rt_isempty \
rt_hasnoband \
drop_rt_empty_raster_test \
rt_metadata \
rt_raster2worldcoord \
rt_world2rastercoord
TEST_BANDPROPS = \
create_rt_band_properties_test \
rt_band_properties \
rt_set_band_properties \
rt_summarystats \
......@@ -79,7 +74,6 @@ TEST_BANDPROPS = \
rt_valuepercent \
rt_bandmetadata \
rt_pixelvalue \
drop_rt_band_properties_test \
rt_neighborhood \
rt_nearestvalue \
rt_pixelofvalue \
......@@ -90,16 +84,12 @@ TEST_BANDPROPS = \
TEST_UTILITY = \
rt_utility \
create_rt_mapalgebra_test \
rt_mapalgebraexpr \
rt_mapalgebrafct \
rt_mapalgebraexpr_2raster \
rt_mapalgebrafct_2raster \
drop_rt_mapalgebra_test \
create_rt_mapalgebrafctngb_test \
rt_mapalgebrafctngb \
rt_mapalgebrafctngb_userfunc \
drop_rt_mapalgebrafctngb_test \
rt_reclass \
rt_resample \
rt_asraster \
......@@ -108,7 +98,6 @@ TEST_UTILITY = \
rt_union
TEST_GIST = \
create_rt_gist_test \
rt_above \
rt_below \
rt_contained \
......@@ -120,9 +109,8 @@ TEST_GIST = \
rt_overleft \
rt_overright \
rt_right \
rt_same \
drop_rt_gist_test
rt_same
TEST_SREL = \
rt_intersects \
rt_overlaps \
......
-----------------------------------------------------------------------
-- $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
);
-----------------------------------------------------------------------
-- $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
-----------------------------------------------------------------------
-- $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);
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;
--
-- 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';
-----------------------------------------------------------------------
-- $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)
||