mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-24 00:52:40 +00:00
Added regression tests for ST_Within(raster, raster). Ticket is #1923.
git-svn-id: http://svn.osgeo.org/postgis/trunk@10099 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
d8e4b66e0b
commit
2ed157c71e
|
@ -128,6 +128,7 @@ TEST_SREL = \
|
|||
rt_overlaps \
|
||||
rt_touches \
|
||||
rt_contains \
|
||||
rt_within \
|
||||
rt_samealignment
|
||||
|
||||
TEST_BUGS = \
|
||||
|
|
199
raster/test/regress/rt_within.sql
Normal file
199
raster/test/regress/rt_within.sql
Normal file
|
@ -0,0 +1,199 @@
|
|||
SET client_min_messages TO warning;
|
||||
|
||||
DROP TABLE IF EXISTS raster_within_rast;
|
||||
CREATE TABLE raster_within_rast (
|
||||
rid integer,
|
||||
rast raster
|
||||
);
|
||||
CREATE OR REPLACE FUNCTION make_test_raster(
|
||||
rid integer,
|
||||
width integer DEFAULT 2, height integer DEFAULT 2,
|
||||
ul_x double precision DEFAULT 0, ul_y double precision DEFAULT 0,
|
||||
skew_x double precision DEFAULT 0, skew_y double precision DEFAULT 0
|
||||
)
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
x int;
|
||||
y int;
|
||||
rast raster;
|
||||
BEGIN
|
||||
rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0);
|
||||
rast := ST_AddBand(rast, 1, '8BUI', 1, 0);
|
||||
|
||||
|
||||
INSERT INTO raster_within_rast VALUES (rid, rast);
|
||||
|
||||
RETURN;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
SELECT make_test_raster(0, 2, 2, -1, -1);
|
||||
SELECT make_test_raster(1, 2, 2);
|
||||
SELECT make_test_raster(2, 3, 3);
|
||||
DROP FUNCTION make_test_raster(integer, integer, integer, double precision, double precision, double precision, double precision);
|
||||
|
||||
INSERT INTO raster_within_rast VALUES (10, (
|
||||
SELECT
|
||||
ST_SetValue(rast, 1, 1, 1, 0)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 1
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (11, (
|
||||
SELECT
|
||||
ST_SetValue(rast, 1, 2, 1, 0)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 1
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (12, (
|
||||
SELECT
|
||||
ST_SetValue(
|
||||
ST_SetValue(
|
||||
ST_SetValue(rast, 1, 1, 1, 0),
|
||||
1, 2, 1, 0
|
||||
),
|
||||
1, 1, 2, 0
|
||||
)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 1
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (13, (
|
||||
SELECT
|
||||
ST_SetValue(
|
||||
ST_SetValue(
|
||||
ST_SetValue(
|
||||
ST_SetValue(rast, 1, 1, 1, 0),
|
||||
1, 2, 1, 0
|
||||
),
|
||||
1, 1, 2, 0
|
||||
),
|
||||
1, 2, 2, 0
|
||||
)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 1
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (14, (
|
||||
SELECT
|
||||
ST_SetUpperLeft(rast, 2, 0)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 1
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (15, (
|
||||
SELECT
|
||||
ST_SetScale(
|
||||
ST_SetUpperLeft(rast, 0.1, 0.1),
|
||||
0.4, 0.4
|
||||
)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 1
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (16, (
|
||||
SELECT
|
||||
ST_SetScale(
|
||||
ST_SetUpperLeft(rast, -0.1, 0.1),
|
||||
0.4, 0.4
|
||||
)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 1
|
||||
));
|
||||
|
||||
INSERT INTO raster_within_rast VALUES (20, (
|
||||
SELECT
|
||||
ST_SetUpperLeft(rast, -2, -2)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 2
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (21, (
|
||||
SELECT
|
||||
ST_SetValue(
|
||||
ST_SetValue(
|
||||
ST_SetValue(rast, 1, 1, 1, 0),
|
||||
1, 2, 2, 0
|
||||
),
|
||||
1, 3, 3, 0
|
||||
)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 20
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (22, (
|
||||
SELECT
|
||||
ST_SetValue(
|
||||
ST_SetValue(
|
||||
rast, 1, 3, 2, 0
|
||||
),
|
||||
1, 2, 3, 0
|
||||
)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 21
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (23, (
|
||||
SELECT
|
||||
ST_SetValue(
|
||||
ST_SetValue(
|
||||
rast, 1, 3, 1, 0
|
||||
),
|
||||
1, 1, 3, 0
|
||||
)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 22
|
||||
));
|
||||
|
||||
INSERT INTO raster_within_rast VALUES (30, (
|
||||
SELECT
|
||||
ST_SetSkew(rast, -0.5, 0.5)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 2
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (31, (
|
||||
SELECT
|
||||
ST_SetSkew(rast, -1, 1)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 2
|
||||
));
|
||||
INSERT INTO raster_within_rast VALUES (32, (
|
||||
SELECT
|
||||
ST_SetSkew(rast, 1, -1)
|
||||
FROM raster_within_rast
|
||||
WHERE rid = 2
|
||||
));
|
||||
|
||||
SELECT
|
||||
'1.1',
|
||||
r1.rid,
|
||||
r2.rid,
|
||||
ST_Within(r1.rast, NULL, r2.rast, NULL)
|
||||
FROM raster_within_rast r1
|
||||
JOIN raster_within_rast r2
|
||||
ON r1.rid != r2.rid
|
||||
WHERE r1.rid = 0;
|
||||
|
||||
SELECT
|
||||
'1.2',
|
||||
r1.rid,
|
||||
r2.rid,
|
||||
ST_Within(r1.rast, 1, r2.rast, 1)
|
||||
FROM raster_within_rast r1
|
||||
JOIN raster_within_rast r2
|
||||
ON r1.rid != r2.rid
|
||||
WHERE r1.rid = 0;
|
||||
|
||||
SELECT
|
||||
'1.3',
|
||||
r1.rid,
|
||||
r2.rid,
|
||||
ST_Within(r1.rast, NULL, r2.rast, NULL)
|
||||
FROM raster_within_rast r1
|
||||
JOIN raster_within_rast r2
|
||||
ON r1.rid != r2.rid
|
||||
WHERE r2.rid = 0;
|
||||
|
||||
SELECT
|
||||
'1.4',
|
||||
r1.rid,
|
||||
r2.rid,
|
||||
ST_Within(r1.rast, 1, r2.rast, 1)
|
||||
FROM raster_within_rast r1
|
||||
JOIN raster_within_rast r2
|
||||
ON r1.rid != r2.rid
|
||||
WHERE r2.rid = 0;
|
||||
|
||||
DROP TABLE IF EXISTS raster_within_rast;
|
64
raster/test/regress/rt_within_expected
Normal file
64
raster/test/regress/rt_within_expected
Normal file
|
@ -0,0 +1,64 @@
|
|||
1.1|0|1|f
|
||||
1.1|0|2|f
|
||||
1.1|0|10|f
|
||||
1.1|0|11|f
|
||||
1.1|0|12|f
|
||||
1.1|0|13|f
|
||||
1.1|0|14|f
|
||||
1.1|0|15|f
|
||||
1.1|0|16|f
|
||||
1.1|0|20|t
|
||||
1.1|0|21|t
|
||||
1.1|0|22|t
|
||||
1.1|0|23|t
|
||||
1.1|0|30|f
|
||||
1.1|0|31|f
|
||||
1.1|0|32|f
|
||||
1.2|0|1|f
|
||||
1.2|0|2|f
|
||||
1.2|0|10|f
|
||||
1.2|0|11|f
|
||||
1.2|0|12|f
|
||||
1.2|0|13|f
|
||||
1.2|0|14|f
|
||||
1.2|0|15|f
|
||||
1.2|0|16|f
|
||||
1.2|0|20|t
|
||||
1.2|0|21|f
|
||||
1.2|0|22|f
|
||||
1.2|0|23|f
|
||||
1.2|0|30|f
|
||||
1.2|0|31|f
|
||||
1.2|0|32|f
|
||||
1.3|1|0|f
|
||||
1.3|2|0|f
|
||||
1.3|10|0|f
|
||||
1.3|11|0|f
|
||||
1.3|12|0|f
|
||||
1.3|13|0|f
|
||||
1.3|14|0|f
|
||||
1.3|15|0|t
|
||||
1.3|16|0|t
|
||||
1.3|20|0|f
|
||||
1.3|21|0|f
|
||||
1.3|22|0|f
|
||||
1.3|23|0|f
|
||||
1.3|30|0|f
|
||||
1.3|31|0|f
|
||||
1.3|32|0|f
|
||||
1.4|1|0|f
|
||||
1.4|2|0|f
|
||||
1.4|10|0|f
|
||||
1.4|11|0|f
|
||||
1.4|12|0|f
|
||||
1.4|13|0|f
|
||||
1.4|14|0|f
|
||||
1.4|15|0|t
|
||||
1.4|16|0|t
|
||||
1.4|20|0|f
|
||||
1.4|21|0|f
|
||||
1.4|22|0|f
|
||||
1.4|23|0|f
|
||||
1.4|30|0|f
|
||||
1.4|31|0|f
|
||||
1.4|32|0|f
|
Loading…
Reference in a new issue