From 6b50e23c33df99c6ba7e1d1d0213b3ffc797acd2 Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Tue, 24 Jul 2012 18:01:31 +0000 Subject: [PATCH] Added ST_Disjoint(raster, raster), regression tests and docs. Ticket is git-svn-id: http://svn.osgeo.org/postgis/trunk@10110 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 4 +- doc/reference_raster.xml | 372 ++++++++++++++--------- raster/rt_core/rt_api.h | 5 + raster/rt_pg/rtpostgis.sql.in.c | 32 +- raster/test/regress/Makefile.in | 1 + raster/test/regress/rt_disjoint.sql | 174 +++++++++++ raster/test/regress/rt_disjoint_expected | 32 ++ 7 files changed, 465 insertions(+), 155 deletions(-) create mode 100644 raster/test/regress/rt_disjoint.sql create mode 100644 raster/test/regress/rt_disjoint_expected diff --git a/NEWS b/NEWS index 262f30630..0a2f91bc5 100644 --- a/NEWS +++ b/NEWS @@ -14,8 +14,8 @@ PostGIS 2.1.0 - ST_PixelAsCentroid, ST_PixelAsCentroids (Bborie Park / UC Davis) - ST_Raster2WorldCoord, ST_World2RasterCoord (Bborie Park / UC Davis) - Additional raster/raster spatial relationship functions - (ST_Overlaps, ST_Touches, ST_Contains, ST_ContainsProperly, ST_Covers, - ST_CoveredBy, ST_Within) + (ST_Contains, ST_ContainsProperly, ST_Covers, ST_CoveredBy, ST_Disjoint, + ST_Overlaps, ST_Touches, ST_Within) (Bborie Park / UC Davis) - #1643, Tiger Geocoder - Tiger 2011 loader (Regina Obe / Paragon Corporation) Funded by Hunter Systems Group diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index 2efcefa52..e0d76d22f 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -8722,18 +8722,19 @@ a_rid | b_rid | overleft Raster and Raster Band Spatial Relationships - - - ST_Intersects - - Return true if raster rastA spatially intersects raster rastB. - - - + + + ST_Contains + + Return true if no points of raster rastB lie in the exterior of raster rastA and at least one point of the interior of rastB lies in the interior of rastA. + + - - boolean ST_Intersects + + + + boolean ST_Contains raster rastA @@ -8750,10 +8751,10 @@ a_rid | b_rid | overleft integer nbandB - + - boolean ST_Intersects + boolean ST_Contains raster rastA @@ -8762,111 +8763,154 @@ a_rid | b_rid | overleft raster rastB - + + + + + + + Description + + + Raster rastA contains rastB if and only if no points of rastB lie in the exterior of rastA and at least one point of the interior of rastB lies in the interior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. + + + + + This function will make use of any indexes that may be available on the rasters. + + + + + To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Contains(ST_Polygon(raster), geometry) or ST_Contains(geometry, ST_Polygon(raster)). + + + + + + ST_Contains() is the inverse of ST_Within(). So, ST_Contains(rastA, rastB) implies ST_Within(rastB, rastA). + + + + Availability: 2.1.0 + + + + Examples + + +-- needs an example + + + + See Also + + , + + + + + + + + ST_ContainsProperly + + Return true if rastB intersects the interior of rastA but not the boundary or exterior of rastA. + + + + + - boolean ST_Intersects - - raster - rast - + boolean ST_ContainsProperly - integer - nband + raster + rastA - geometry - geommin + integer + nbandA - - - - boolean ST_Intersects - raster - rast + raster + rastB - geometry - geommin - - - integer - nband=NULL + integer + nbandB - + - - boolean ST_Intersects + + boolean ST_ContainsProperly - geometry - geommin + raster + rastA - raster - rast - - - integer - nband=NULL + raster + rastB - + - + - + Description - Return true if raster rastA spatially intersects raster rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. + Raster rastA contains properly rastB if rastB intersects the interior of rastA but not the boundary or exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. + + + + Raster rastA does not contain properly itself but does contain itself. - This operand will make use of any indexes that may be available on the rasters. + This function will make use of any indexes that may be available on the rasters. - - - Enhanced: 2.0.0 support raster/raster intersects was introduced. - - + - Changed: 2.1.0 The behavior of the ST_Intersects(raster, geometry) variants changed to match that of ST_Intersects(geometry, raster). + To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_ContainsProperly(ST_Polygon(raster), geometry) or ST_ContainsProperly(geometry, ST_Polygon(raster)). - + - + Availability: 2.1.0 + - + Examples --- needs a new example +-- needs an example - - - See Also - - - - - + + + See Also + + , + + + + - + - ST_Overlaps + ST_Covers - Return true if raster rastA and rastB intersect but one does not completely contain the other. + Return true if no points of raster rastB lie outside raster rastA. - boolean ST_Overlaps + boolean ST_Covers raster rastA @@ -8886,7 +8930,7 @@ a_rid | b_rid | overleft - boolean ST_Overlaps + boolean ST_Covers raster rastA @@ -8904,21 +8948,21 @@ a_rid | b_rid | overleft Description - Return true if raster rastA spatially overlaps raster rastB. This means that rastA and rastB intersect but one does not completely contain the other. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. + Raster rastA covers rastB if and only if no points of rastB lie in the exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. - This operand will make use of any indexes that may be available on the rasters. + This function will make use of any indexes that may be available on the rasters. - To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Overlaps(ST_Polygon(raster), geometry). + To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Covers(ST_Polygon(raster), geometry) or ST_Covers(geometry, ST_Polygon(raster)). - + Availability: 2.1.0 @@ -8932,23 +8976,24 @@ a_rid | b_rid | overleft See Also - + , + - + - ST_Touches + ST_CoveredBy - Return true if raster rastA and rastB have at least one point in common but their interiors do not intersect. + Return true if no points of raster rastA lie outside raster rastB. - boolean ST_Touches + boolean ST_CoveredBy raster rastA @@ -8968,7 +9013,7 @@ a_rid | b_rid | overleft - boolean ST_Touches + boolean ST_CoveredBy raster rastA @@ -8986,18 +9031,18 @@ a_rid | b_rid | overleft Description - Return true if raster rastA spatially touches raster rastB. This means that rastA and rastB have at least one point in common but their interiors do not intersect. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. + Raster rastA is covered by rastB if and only if no points of rastA lie in the exterior of rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. - This operand will make use of any indexes that may be available on the rasters. + This function will make use of any indexes that may be available on the rasters. - To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Touches(ST_Polygon(raster), geometry). + To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_CoveredBy(ST_Polygon(raster), geometry) or ST_CoveredBy(geometry, ST_Polygon(raster)). @@ -9014,23 +9059,24 @@ a_rid | b_rid | overleft See Also - + , + - + - ST_Contains + ST_Disjoint - Return true if no points of raster rastB lie in the exterior of raster rastA and at least one point of the interior of rastB lies in the interior of rastA. + Return true if raster rastA does not spatially intersect rastB. - boolean ST_Contains + boolean ST_Disjoint raster rastA @@ -9050,7 +9096,7 @@ a_rid | b_rid | overleft - boolean ST_Contains + boolean ST_Disjoint raster rastA @@ -9068,24 +9114,18 @@ a_rid | b_rid | overleft Description - Raster rastA contains rastB if and only if no points of rastB lie in the exterior of rastA and at least one point of the interior of rastB lies in the interior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. + Raster rastA and rastB are disjointed if they do not share any space together. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. - This operand will make use of any indexes that may be available on the rasters. - - - - - - To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Contains(ST_Polygon(raster), geometry) or ST_Contains(geometry, ST_Polygon(raster)). + This function does NOT use any indexes. - ST_Contains() is the inverse of ST_Within(). So, ST_Contains(rastA, rastB) implies ST_Within(rastB, rastA). + To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Disjoint(ST_Polygon(raster), geometry). @@ -9102,24 +9142,21 @@ a_rid | b_rid | overleft See Also - , - + - + - ST_ContainsProperly - - Return true if rastB intersects the interior of rastA but not the boundary or exterior of rastA. - + ST_Intersects + Return true if raster rastA spatially intersects raster rastB. - boolean ST_ContainsProperly + boolean ST_Intersects raster rastA @@ -9139,7 +9176,7 @@ a_rid | b_rid | overleft - boolean ST_ContainsProperly + boolean ST_Intersects raster rastA @@ -9150,6 +9187,54 @@ a_rid | b_rid | overleft + + boolean ST_Intersects + + raster + rast + + + integer + nband + + + geometry + geommin + + + + + boolean ST_Intersects + + raster + rast + + + geometry + geommin + + + integer + nband=NULL + + + + + boolean ST_Intersects + + geometry + geommin + + + raster + rast + + + integer + nband=NULL + + + @@ -9157,56 +9242,55 @@ a_rid | b_rid | overleft Description - Raster rastA contains properly rastB if rastB intersects the interior of rastA but not the boundary or exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. - - - - Raster rastA does not contain properly itself but does contain itself. + Return true if raster rastA spatially intersects raster rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. - This operand will make use of any indexes that may be available on the rasters. + This function will make use of any indexes that may be available on the rasters. - + + Enhanced: 2.0.0 support raster/raster intersects was introduced. + + + - To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_ContainsProperly(ST_Polygon(raster), geometry) or ST_ContainsProperly(geometry, ST_Polygon(raster)). + Changed: 2.1.0 The behavior of the ST_Intersects(raster, geometry) variants changed to match that of ST_Intersects(geometry, raster). - + - Availability: 2.1.0 Examples - --- needs an example +-- needs a new example + See Also - , - + , + - + - ST_Covers + ST_Overlaps - Return true if no points of raster rastB lie outside raster rastA. + Return true if raster rastA and rastB intersect but one does not completely contain the other. - boolean ST_Covers + boolean ST_Overlaps raster rastA @@ -9226,7 +9310,7 @@ a_rid | b_rid | overleft - boolean ST_Covers + boolean ST_Overlaps raster rastA @@ -9244,21 +9328,21 @@ a_rid | b_rid | overleft Description - Raster rastA covers rastB if and only if no points of rastB lie in the exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. + Return true if raster rastA spatially overlaps raster rastB. This means that rastA and rastB intersect but one does not completely contain the other. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. - This operand will make use of any indexes that may be available on the rasters. + This function will make use of any indexes that may be available on the rasters. - To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Covers(ST_Polygon(raster), geometry) or ST_Covers(geometry, ST_Polygon(raster)). + To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Overlaps(ST_Polygon(raster), geometry). - + Availability: 2.1.0 @@ -9272,24 +9356,23 @@ a_rid | b_rid | overleft See Also - , - + - + - ST_CoveredBy + ST_Touches - Return true if no points of raster rastA lie outside raster rastB. + Return true if raster rastA and rastB have at least one point in common but their interiors do not intersect. - boolean ST_CoveredBy + boolean ST_Touches raster rastA @@ -9309,7 +9392,7 @@ a_rid | b_rid | overleft - boolean ST_CoveredBy + boolean ST_Touches raster rastA @@ -9327,18 +9410,18 @@ a_rid | b_rid | overleft Description - Raster rastA is covered by rastB if and only if no points of rastA lie in the exterior of rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. + Return true if raster rastA spatially touches raster rastB. This means that rastA and rastB have at least one point in common but their interiors do not intersect. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test. - This operand will make use of any indexes that may be available on the rasters. + This function will make use of any indexes that may be available on the rasters. - To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_CoveredBy(ST_Polygon(raster), geometry) or ST_CoveredBy(geometry, ST_Polygon(raster)). + To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Touches(ST_Polygon(raster), geometry). @@ -9355,8 +9438,7 @@ a_rid | b_rid | overleft See Also - , - + diff --git a/raster/rt_core/rt_api.h b/raster/rt_core/rt_api.h index 7ac3f76fe..73d04660c 100644 --- a/raster/rt_core/rt_api.h +++ b/raster/rt_core/rt_api.h @@ -181,6 +181,11 @@ typedef enum { /** * GEOS spatial relationship tests available + * + * GEOS tests not available are: + * intersects + * crosses + * disjoint */ typedef enum { GSR_OVERLAPS = 0, diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index 8dc9162a6..811d59694 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -3124,7 +3124,7 @@ CREATE OR REPLACE FUNCTION _st_intersects(rast1 raster, nband1 integer, rast2 ra CREATE OR REPLACE FUNCTION st_intersects(rast1 raster, nband1 integer, rast2 raster, nband2 integer) RETURNS boolean - AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_intersects(st_convexhull($1), st_convexhull($3)) ELSE _st_intersects($1, $2, $3, $4) END $$ + AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_intersects(st_convexhull($1), st_convexhull($3)) ELSE _st_intersects($1, $2, $3, $4) END $$ LANGUAGE 'sql' IMMUTABLE COST 1000; @@ -3302,7 +3302,7 @@ CREATE OR REPLACE FUNCTION _st_overlaps(rast1 raster, nband1 integer, rast2 rast CREATE OR REPLACE FUNCTION st_overlaps(rast1 raster, nband1 integer, rast2 raster, nband2 integer) RETURNS boolean - AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_overlaps(st_convexhull($1), st_convexhull($3)) ELSE _st_overlaps($1, $2, $3, $4) END $$ + AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_overlaps(st_convexhull($1), st_convexhull($3)) ELSE _st_overlaps($1, $2, $3, $4) END $$ LANGUAGE 'sql' IMMUTABLE COST 1000; @@ -3324,7 +3324,7 @@ CREATE OR REPLACE FUNCTION _st_touches(rast1 raster, nband1 integer, rast2 raste CREATE OR REPLACE FUNCTION st_touches(rast1 raster, nband1 integer, rast2 raster, nband2 integer) RETURNS boolean - AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_touches(st_convexhull($1), st_convexhull($3)) ELSE _st_touches($1, $2, $3, $4) END $$ + AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_touches(st_convexhull($1), st_convexhull($3)) ELSE _st_touches($1, $2, $3, $4) END $$ LANGUAGE 'sql' IMMUTABLE COST 1000; @@ -3346,7 +3346,7 @@ CREATE OR REPLACE FUNCTION _st_contains(rast1 raster, nband1 integer, rast2 rast CREATE OR REPLACE FUNCTION st_contains(rast1 raster, nband1 integer, rast2 raster, nband2 integer) RETURNS boolean - AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_contains(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($1, $2, $3, $4) END $$ + AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_contains(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($1, $2, $3, $4) END $$ LANGUAGE 'sql' IMMUTABLE COST 1000; @@ -3368,7 +3368,7 @@ CREATE OR REPLACE FUNCTION _st_containsproperly(rast1 raster, nband1 integer, ra CREATE OR REPLACE FUNCTION st_containsproperly(rast1 raster, nband1 integer, rast2 raster, nband2 integer) RETURNS boolean - AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_containsproperly(st_convexhull($1), st_convexhull($3)) ELSE _st_containsproperly($1, $2, $3, $4) END $$ + AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_containsproperly(st_convexhull($1), st_convexhull($3)) ELSE _st_containsproperly($1, $2, $3, $4) END $$ LANGUAGE 'sql' IMMUTABLE COST 1000; @@ -3390,7 +3390,7 @@ CREATE OR REPLACE FUNCTION _st_covers(rast1 raster, nband1 integer, rast2 raster CREATE OR REPLACE FUNCTION st_covers(rast1 raster, nband1 integer, rast2 raster, nband2 integer) RETURNS boolean - AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_covers(st_convexhull($1), st_convexhull($3)) ELSE _st_covers($1, $2, $3, $4) END $$ + AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_covers(st_convexhull($1), st_convexhull($3)) ELSE _st_covers($1, $2, $3, $4) END $$ LANGUAGE 'sql' IMMUTABLE COST 1000; @@ -3412,7 +3412,7 @@ CREATE OR REPLACE FUNCTION _st_coveredby(rast1 raster, nband1 integer, rast2 ras CREATE OR REPLACE FUNCTION st_coveredby(rast1 raster, nband1 integer, rast2 raster, nband2 integer) RETURNS boolean - AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_coveredby(st_convexhull($1), st_convexhull($3)) ELSE _st_coveredby($1, $2, $3, $4) END $$ + AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_coveredby(st_convexhull($1), st_convexhull($3)) ELSE _st_coveredby($1, $2, $3, $4) END $$ LANGUAGE 'sql' IMMUTABLE COST 1000; @@ -3434,7 +3434,7 @@ CREATE OR REPLACE FUNCTION _st_within(rast1 raster, nband1 integer, rast2 raster CREATE OR REPLACE FUNCTION st_within(rast1 raster, nband1 integer, rast2 raster, nband2 integer) RETURNS boolean - AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_within(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($3, $4, $1, $2) END $$ + AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_within(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($3, $4, $1, $2) END $$ LANGUAGE 'sql' IMMUTABLE COST 1000; @@ -3444,6 +3444,22 @@ CREATE OR REPLACE FUNCTION st_within(rast1 raster, rast2 raster) LANGUAGE 'sql' IMMUTABLE COST 1000; +----------------------------------------------------------------------- +-- ST_Disjoint(raster, raster) +----------------------------------------------------------------------- + +CREATE OR REPLACE FUNCTION st_disjoint(rast1 raster, nband1 integer, rast2 raster, nband2 integer) + RETURNS boolean + AS $$ SELECT CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_disjoint(st_convexhull($1), st_convexhull($3)) ELSE NOT _st_intersects($1, $2, $3, $4) END $$ + LANGUAGE 'sql' IMMUTABLE + COST 1000; + +CREATE OR REPLACE FUNCTION st_disjoint(rast1 raster, rast2 raster) + RETURNS boolean + AS $$ SELECT st_disjoint($1, NULL::integer, $2, NULL::integer) $$ + LANGUAGE 'sql' IMMUTABLE + COST 1000; + ----------------------------------------------------------------------- -- ST_Intersection(geometry, raster) in geometry-space ----------------------------------------------------------------------- diff --git a/raster/test/regress/Makefile.in b/raster/test/regress/Makefile.in index ec3e355e4..9e83d3f08 100644 --- a/raster/test/regress/Makefile.in +++ b/raster/test/regress/Makefile.in @@ -132,6 +132,7 @@ TEST_SREL = \ rt_covers \ rt_coveredby \ rt_within \ + rt_disjoint \ rt_samealignment TEST_BUGS = \ diff --git a/raster/test/regress/rt_disjoint.sql b/raster/test/regress/rt_disjoint.sql new file mode 100644 index 000000000..afbc39aae --- /dev/null +++ b/raster/test/regress/rt_disjoint.sql @@ -0,0 +1,174 @@ +SET client_min_messages TO warning; + +DROP TABLE IF EXISTS raster_disjoint_rast; +CREATE TABLE raster_disjoint_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_disjoint_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_disjoint_rast VALUES (10, ( + SELECT + ST_SetValue(rast, 1, 1, 1, 0) + FROM raster_disjoint_rast + WHERE rid = 1 +)); +INSERT INTO raster_disjoint_rast VALUES (11, ( + SELECT + ST_SetValue(rast, 1, 2, 1, 0) + FROM raster_disjoint_rast + WHERE rid = 1 +)); +INSERT INTO raster_disjoint_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_disjoint_rast + WHERE rid = 1 +)); +INSERT INTO raster_disjoint_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_disjoint_rast + WHERE rid = 1 +)); +INSERT INTO raster_disjoint_rast VALUES (14, ( + SELECT + ST_SetUpperLeft(rast, 2, 0) + FROM raster_disjoint_rast + WHERE rid = 1 +)); +INSERT INTO raster_disjoint_rast VALUES (15, ( + SELECT + ST_SetScale( + ST_SetUpperLeft(rast, 0.1, 0.1), + 0.4, 0.4 + ) + FROM raster_disjoint_rast + WHERE rid = 1 +)); +INSERT INTO raster_disjoint_rast VALUES (16, ( + SELECT + ST_SetScale( + ST_SetUpperLeft(rast, -0.1, 0.1), + 0.4, 0.4 + ) + FROM raster_disjoint_rast + WHERE rid = 1 +)); + +INSERT INTO raster_disjoint_rast VALUES (20, ( + SELECT + ST_SetUpperLeft(rast, -2, -2) + FROM raster_disjoint_rast + WHERE rid = 2 +)); +INSERT INTO raster_disjoint_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_disjoint_rast + WHERE rid = 20 +)); +INSERT INTO raster_disjoint_rast VALUES (22, ( + SELECT + ST_SetValue( + ST_SetValue( + rast, 1, 3, 2, 0 + ), + 1, 2, 3, 0 + ) + FROM raster_disjoint_rast + WHERE rid = 21 +)); +INSERT INTO raster_disjoint_rast VALUES (23, ( + SELECT + ST_SetValue( + ST_SetValue( + rast, 1, 3, 1, 0 + ), + 1, 1, 3, 0 + ) + FROM raster_disjoint_rast + WHERE rid = 22 +)); + +INSERT INTO raster_disjoint_rast VALUES (30, ( + SELECT + ST_SetSkew(rast, -0.5, 0.5) + FROM raster_disjoint_rast + WHERE rid = 2 +)); +INSERT INTO raster_disjoint_rast VALUES (31, ( + SELECT + ST_SetSkew(rast, -1, 1) + FROM raster_disjoint_rast + WHERE rid = 2 +)); +INSERT INTO raster_disjoint_rast VALUES (32, ( + SELECT + ST_SetSkew(rast, 1, -1) + FROM raster_disjoint_rast + WHERE rid = 2 +)); + +SELECT + '1.1', + r1.rid, + r2.rid, + ST_Disjoint(r1.rast, NULL, r2.rast, NULL) +FROM raster_disjoint_rast r1 +JOIN raster_disjoint_rast r2 + ON r1.rid != r2.rid +WHERE r1.rid = 0; + +SELECT + '1.2', + r1.rid, + r2.rid, + ST_Disjoint(r1.rast, 1, r2.rast, 1) +FROM raster_disjoint_rast r1 +JOIN raster_disjoint_rast r2 + ON r1.rid != r2.rid +WHERE r1.rid = 0; + +DROP TABLE IF EXISTS raster_disjoint_rast; diff --git a/raster/test/regress/rt_disjoint_expected b/raster/test/regress/rt_disjoint_expected new file mode 100644 index 000000000..a3fbbe57f --- /dev/null +++ b/raster/test/regress/rt_disjoint_expected @@ -0,0 +1,32 @@ +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|t +1.1|0|15|f +1.1|0|16|f +1.1|0|20|f +1.1|0|21|f +1.1|0|22|f +1.1|0|23|f +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|t +1.2|0|14|t +1.2|0|15|f +1.2|0|16|f +1.2|0|20|f +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 -- 2.40.0