From 2052f3c2da2509592ea8a223aa3ba2e105ccc404 Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Mon, 23 Jul 2012 17:49:38 +0000 Subject: [PATCH] Removed all raster/geometry variants of ST_Intersects, ST_Overlaps, ST_Touches and ST_Contains. git-svn-id: http://svn.osgeo.org/postgis/trunk@10092 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 11 +- doc/reference_raster.xml | 194 +++---------------- raster/rt_pg/rtpostgis.sql.in.c | 271 +-------------------------- raster/rt_pg/rtpostgis_drop.sql.in.c | 27 ++- 4 files changed, 57 insertions(+), 446 deletions(-) diff --git a/NEWS b/NEWS index 5aaca14c2..3c629c197 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ PostGIS 2.1.0 2013/MM/DD +* Important / Breaking Changes * + + - ST_Intersects(raster, geometry) and ST_Intersects(geometry, raster) + has been removed. Use ST_Intersects(ST_Polygon(raster), geometry) + instead. + * New Features * - ST_DelaunayTriangles (Sandro Santilli / Vizzuality) @@ -8,8 +14,9 @@ PostGIS 2.1.0 - ST_PixelAsPoint, ST_PixelAsPoints (Bborie Park / UC Davis) - ST_PixelAsCentroid, ST_PixelAsCentroids (Bborie Park / UC Davis) - ST_Raster2WorldCoord, ST_World2RasterCoord (Bborie Park / UC Davis) - - Additional raster/raster and raster/geometry spatial relationship - functions (ST_Overlaps, ST_Touches) (Bborie Park / UC Davis) + - Additional raster/raster spatial relationship functions + (ST_Overlaps, ST_Touches, ST_Contains) + (Bborie Park / UC Davis) - #1643, Tiger Geocoder - Tiger 2011 loader (Regina Obe / Paragon Corporation) Funded by Hunter Systems Group - GEOMETRYCOLLECTION support for ST_MakeValid (Sandro Santilli / Vizzuality) diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index 07f992ef8..4cf3f643d 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -8726,7 +8726,7 @@ a_rid | b_rid | overleft ST_Intersects - Return true if the raster spatially intersects a separate raster or geometry. 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 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. @@ -8764,54 +8764,6 @@ 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 - - - @@ -8819,39 +8771,33 @@ a_rid | b_rid | overleft Description - Return true if the raster spatially intersects a separate raster or geometry. 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 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. + - Depending on the order that the raster and geometry is passed to ST_Intersects(), the test will operate in either raster-space or geometry-space. If ST_Intersects(raster, ....), the test is in raster-space (the geometry is converted to a raster). If ST_Intersects(geometry, ...), the test is in geometry-space (the raster is converted to a set of pixel polygons). + This operand will make use of any indexes that may be available on the rasters. - + + + Enhanced: 2.0.0 support raster/raster intersects was introduced. + + + - This operand will make use of any indexes that may be available on the geometries / rasters. + Changed: The ST_Intersects(raster, geometry) and ST_Intersects(geometry, raster) variants present before PostGIS 2.1.0 have been removed. Use ST_Intersects(ST_Polygon(raster), geometry) instead. - - - Enhanced: 2.0.0 support raster/raster intersects was introduced. + + Examples - SELECT A.rid, g.gid , ST_Intersects(A.rast, g.geom) As inter -FROM dummy_rast AS A CROSS JOIN - (VALUES (1, ST_Point(3427928, 5793243.85) ) , - (2, ST_GeomFromText('LINESTRING(3427927.85 5793243.75,3427927.8 5793243.75,3427927.8 5793243.8)') ), - (3, ST_GeomFromText('LINESTRING(1 2, 3 4)') ) - ) As g(gid,geom) -WHERE A.rid =2 ; - - rid | gid | inter ------+-----+------- - 2 | 1 | t - 2 | 2 | t - 2 | 3 | f - + +-- needs a new example + See Also @@ -8865,7 +8811,7 @@ WHERE A.rid =2 ; ST_Overlaps - Return true if the raster spatially overlaps a separate raster or geometry. 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. 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. @@ -8903,54 +8849,6 @@ WHERE A.rid =2 ; - - boolean ST_Overlaps - - raster - rast - - - integer - nband - - - geometry - geommin - - - - - boolean ST_Overlaps - - raster - rast - - - geometry - geommin - - - integer - nband=NULL - - - - - boolean ST_Overlaps - - geometry - geommin - - - raster - rast - - - integer - nband=NULL - - - @@ -8958,12 +8856,12 @@ WHERE A.rid =2 ; Description - Return true if the raster spatially overlaps a separate raster or geometry. This means that the raster/raster or raster/geometry combinations 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. + 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 geometries / rasters. + This operand will make use of any indexes that may be available on the rasters. @@ -8989,7 +8887,7 @@ WHERE A.rid =2 ; ST_Touches - Return true if the raster spatially touch a separate raster or geometry. 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 touch 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. @@ -9027,54 +8925,6 @@ WHERE A.rid =2 ; - - boolean ST_Touches - - raster - rast - - - integer - nband - - - geometry - geommin - - - - - boolean ST_Touches - - raster - rast - - - geometry - geommin - - - integer - nband=NULL - - - - - boolean ST_Touches - - geometry - geommin - - - raster - rast - - - integer - nband=NULL - - - @@ -9082,12 +8932,12 @@ WHERE A.rid =2 ; Description - Return true if the raster spatially touches a separate raster or geometry. This means that the raster/raster or raster/geometry combinations 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. + 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 geometries / rasters. + This operand will make use of any indexes that may be available on the rasters. diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index 58155d820..a2c84dde3 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -3049,7 +3049,7 @@ CREATE OPERATOR && ( ); ----------------------------------------------------------------------- --- Raster/(Raster|Geometry) Spatial Relationship +-- Raster/Raster Spatial Relationship ----------------------------------------------------------------------- ----------------------------------------------------------------------- @@ -3134,90 +3134,6 @@ CREATE OR REPLACE FUNCTION st_intersects(rast1 raster, rast2 raster) LANGUAGE 'sql' IMMUTABLE COST 1000; ------------------------------------------------------------------------ --- ST_Intersects(raster, geometry) in raster-space ------------------------------------------------------------------------ - -CREATE OR REPLACE FUNCTION _st_intersects(rast raster, geom geometry, nband integer DEFAULT NULL) - RETURNS boolean - AS $$ - DECLARE - gr raster; - scale double precision; - BEGIN - IF ST_Intersects(geom, ST_ConvexHull(rast)) IS NOT TRUE THEN - RETURN FALSE; - ELSEIF nband IS NULL THEN - RETURN TRUE; - END IF; - - -- scale is set to 1/100th of raster for granularity - SELECT least(scalex, scaley) / 100. INTO scale FROM ST_Metadata(rast); - gr := _st_asraster(geom, scale, scale); - IF gr IS NULL THEN - RAISE EXCEPTION 'Unable to convert geometry to a raster'; - RETURN FALSE; - END IF; - - RETURN ST_Intersects(rast, nband, gr, 1); - END; - $$ LANGUAGE 'plpgsql' IMMUTABLE - COST 1000; - -CREATE OR REPLACE FUNCTION st_intersects(rast raster, geom geometry, nband integer DEFAULT NULL) - RETURNS boolean - AS $$ SELECT $1::geometry && $2 AND _st_intersects($1, $2, $3) $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - -CREATE OR REPLACE FUNCTION st_intersects(rast raster, nband integer, geom geometry) - RETURNS boolean - AS $$ SELECT $1::geometry && $3 AND _st_intersects($1, $3, $2) $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - ------------------------------------------------------------------------ --- ST_Intersects(geometry, raster) in geometry-space ------------------------------------------------------------------------ - --- This function can not be STRICT -CREATE OR REPLACE FUNCTION _st_intersects(geom geometry, rast raster, nband integer DEFAULT NULL) - RETURNS boolean AS $$ - DECLARE - convexhull geometry; - hasnodata boolean := TRUE; - surface geometry; - BEGIN - convexhull := ST_ConvexHull(rast); - IF nband IS NOT NULL THEN - SELECT CASE WHEN bmd.nodatavalue IS NULL THEN FALSE ELSE NULL END INTO hasnodata FROM ST_BandMetaData(rast, nband) AS bmd; - END IF; - - IF ST_Intersects(geom, convexhull) IS NOT TRUE THEN - RETURN FALSE; - ELSEIF nband IS NULL OR hasnodata IS FALSE THEN - RETURN TRUE; - END IF; - - -- get band polygon - surface := ST_Polygon(rast, nband); - - IF surface IS NOT NULL THEN - RETURN ST_Intersects(geom, surface); - END IF; - - RETURN FALSE; - END; - $$ LANGUAGE 'plpgsql' IMMUTABLE - COST 1000; - --- This function can not be STRICT -CREATE OR REPLACE FUNCTION st_intersects(geom geometry, rast raster, nband integer DEFAULT NULL) - RETURNS boolean AS - $$ SELECT $1 && $2::geometry AND _st_intersects($1, $2, $3); $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - ----------------------------------------------------------------------- -- ST_Overlaps(raster, raster) ----------------------------------------------------------------------- @@ -3240,59 +3156,6 @@ CREATE OR REPLACE FUNCTION st_overlaps(rast1 raster, rast2 raster) LANGUAGE 'sql' IMMUTABLE COST 1000; ------------------------------------------------------------------------ --- ST_Overlaps(raster, geometry) ------------------------------------------------------------------------ - -CREATE OR REPLACE FUNCTION _st_overlaps(rast raster, geom geometry, nband integer DEFAULT NULL) - RETURNS boolean - AS $$ - DECLARE - gr raster; - scale double precision; - BEGIN - IF ST_Overlaps(geom, ST_ConvexHull(rast)) IS NOT TRUE THEN - RETURN FALSE; - ELSEIF nband IS NULL THEN - RETURN TRUE; - END IF; - - -- scale is set to 1/100th of raster for granularity - SELECT least(scalex, scaley) / 100. INTO scale FROM ST_Metadata(rast); - gr := _st_asraster(geom, scale, scale); - IF gr IS NULL THEN - RAISE EXCEPTION 'Unable to convert geometry to a raster'; - RETURN FALSE; - END IF; - - RETURN ST_Overlaps(rast, nband, gr, 1); - END; - $$ LANGUAGE 'plpgsql' IMMUTABLE - COST 1000; - -CREATE OR REPLACE FUNCTION st_overlaps(rast raster, geom geometry, nband integer DEFAULT NULL) - RETURNS boolean - AS $$ SELECT $1::geometry && $2 AND _st_overlaps($1, $2, $3) $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - -CREATE OR REPLACE FUNCTION st_overlaps(rast raster, nband integer, geom geometry) - RETURNS boolean - AS $$ SELECT $1::geometry && $3 AND _st_overlaps($1, $3, $2) $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - ------------------------------------------------------------------------ --- ST_Overlaps(geometry, raster) ------------------------------------------------------------------------ - --- This function can not be STRICT -CREATE OR REPLACE FUNCTION st_overlaps(geom geometry, rast raster, nband integer DEFAULT NULL) - RETURNS boolean AS - $$ SELECT $1 && $2::geometry AND _st_overlaps($2, $1, $3); $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - ----------------------------------------------------------------------- -- ST_Touches(raster, raster) ----------------------------------------------------------------------- @@ -3315,59 +3178,6 @@ CREATE OR REPLACE FUNCTION st_touches(rast1 raster, rast2 raster) LANGUAGE 'sql' IMMUTABLE COST 1000; ------------------------------------------------------------------------ --- ST_Touches(raster, geometry) ------------------------------------------------------------------------ - -CREATE OR REPLACE FUNCTION _st_touches(rast raster, geom geometry, nband integer DEFAULT NULL) - RETURNS boolean - AS $$ - DECLARE - gr raster; - scale double precision; - BEGIN - IF ST_Touches(geom, ST_ConvexHull(rast)) IS NOT TRUE THEN - RETURN FALSE; - ELSEIF nband IS NULL THEN - RETURN TRUE; - END IF; - - -- scale is set to 1/100th of raster for granularity - SELECT least(scalex, scaley) / 100. INTO scale FROM ST_Metadata(rast); - gr := _st_asraster(geom, scale, scale); - IF gr IS NULL THEN - RAISE EXCEPTION 'Unable to convert geometry to a raster'; - RETURN FALSE; - END IF; - - RETURN ST_Touches(rast, nband, gr, 1); - END; - $$ LANGUAGE 'plpgsql' IMMUTABLE - COST 1000; - -CREATE OR REPLACE FUNCTION st_touches(rast raster, geom geometry, nband integer DEFAULT NULL) - RETURNS boolean - AS $$ SELECT $1::geometry && $2 AND _st_touches($1, $2, $3) $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - -CREATE OR REPLACE FUNCTION st_touches(rast raster, nband integer, geom geometry) - RETURNS boolean - AS $$ SELECT $1::geometry && $3 AND _st_touches($1, $3, $2) $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - ------------------------------------------------------------------------ --- ST_Touches(geometry, raster) ------------------------------------------------------------------------ - --- This function can not be STRICT -CREATE OR REPLACE FUNCTION st_touches(geom geometry, rast raster, nband integer DEFAULT NULL) - RETURNS boolean AS - $$ SELECT $1 && $2::geometry AND _st_touches($2, $1, $3); $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - ----------------------------------------------------------------------- -- ST_Contains(raster, raster) ----------------------------------------------------------------------- @@ -3390,85 +3200,6 @@ CREATE OR REPLACE FUNCTION st_contains(rast1 raster, rast2 raster) LANGUAGE 'sql' IMMUTABLE COST 1000; ------------------------------------------------------------------------ --- ST_Contains(raster, geometry) ------------------------------------------------------------------------ - -CREATE OR REPLACE FUNCTION _st_contains(rast raster, geom geometry, nband integer DEFAULT NULL) - RETURNS boolean - AS $$ - DECLARE - gr raster; - scale double precision; - BEGIN - IF ST_Contains(ST_ConvexHull(rast), geom) IS NOT TRUE THEN - RETURN FALSE; - ELSEIF nband IS NULL THEN - RETURN TRUE; - END IF; - - -- scale is set to 1/100th of raster for granularity - SELECT least(scalex, scaley) / 100. INTO scale FROM ST_Metadata(rast); - gr := _st_asraster(geom, scale, scale); - IF gr IS NULL THEN - RAISE EXCEPTION 'Unable to convert geometry to a raster'; - RETURN FALSE; - END IF; - - RETURN ST_Contains(rast, nband, gr, 1); - END; - $$ LANGUAGE 'plpgsql' IMMUTABLE - COST 1000; - -CREATE OR REPLACE FUNCTION st_contains(rast raster, geom geometry, nband integer DEFAULT NULL) - RETURNS boolean - AS $$ SELECT $1::geometry && $2 AND _st_contains($1, $2, $3) $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - -CREATE OR REPLACE FUNCTION st_contains(rast raster, nband integer, geom geometry) - RETURNS boolean - AS $$ SELECT $1::geometry && $3 AND _st_contains($1, $3, $2) $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - ------------------------------------------------------------------------ --- ST_Contains(geometry, raster) ------------------------------------------------------------------------ - --- This function can not be STRICT -CREATE OR REPLACE FUNCTION _st_contains(geom geometry, rast raster, nband integer DEFAULT NULL) - RETURNS boolean AS $$ - DECLARE - gr raster; - scale double precision; - BEGIN - IF ST_Contains(geom, ST_ConvexHull(rast)) IS NOT TRUE THEN - RETURN FALSE; - ELSEIF nband IS NULL THEN - RETURN TRUE; - END IF; - - -- scale is set to 1/100th of raster for granularity - SELECT least(scalex, scaley) / 100. INTO scale FROM ST_Metadata(rast); - gr := _st_asraster(geom, scale, scale); - IF gr IS NULL THEN - RAISE EXCEPTION 'Unable to convert geometry to a raster'; - RETURN FALSE; - END IF; - - RETURN ST_Contains(gr, 1, rast, nband); - END; - $$ LANGUAGE 'plpgsql' IMMUTABLE - COST 1000; - --- This function can not be STRICT -CREATE OR REPLACE FUNCTION st_contains(geom geometry, rast raster, nband integer DEFAULT NULL) - RETURNS boolean AS - $$ SELECT $1 && $2::geometry AND _st_contains($1, $2, $3); $$ - LANGUAGE 'sql' IMMUTABLE - COST 1000; - ----------------------------------------------------------------------- -- ST_Intersection(geometry, raster) in geometry-space ----------------------------------------------------------------------- diff --git a/raster/rt_pg/rtpostgis_drop.sql.in.c b/raster/rt_pg/rtpostgis_drop.sql.in.c index cfda3c57c..a9d7f6b6c 100644 --- a/raster/rt_pg/rtpostgis_drop.sql.in.c +++ b/raster/rt_pg/rtpostgis_drop.sql.in.c @@ -292,6 +292,7 @@ CREATE OR REPLACE FUNCTION _drop_st_samealignment() $$ LANGUAGE 'plpgsql' VOLATILE; SELECT _drop_st_samealignment(); DROP FUNCTION _drop_st_samealignment(); + DROP FUNCTION IF EXISTS _st_intersects(raster, integer, raster, integer); DROP FUNCTION IF EXISTS st_intersects(raster, integer, raster, integer); DROP FUNCTION IF EXISTS st_intersects(raster, raster); @@ -348,8 +349,30 @@ DROP FUNCTION IF EXISTS st_pixelaspolygons(raster, integer); -- function deprecated DROP FUNCTION IF EXISTS st_bandsurface(raster, integer); --- function deprecated +-- function no longer exists +DROP FUNCTION IF EXISTS st_intersects(raster, integer, geometry); +DROP FUNCTION IF EXISTS st_intersects(raster, geometry, integer); +DROP FUNCTION IF EXISTS st_intersects(geometry, raster, integer); +DROP FUNCTION IF EXISTS _st_intersects(raster, geometry, integer); +DROP FUNCTION IF EXISTS _st_intersects(geometry, raster, integer); + +-- function no longer exists +DROP FUNCTION IF EXISTS st_overlaps(geometry, raster, integer); +DROP FUNCTION IF EXISTS st_overlaps(raster, integer, geometry); +DROP FUNCTION IF EXISTS st_overlaps(raster, geometry, integer); +DROP FUNCTION IF EXISTS _st_overlaps(raster, geometry, integer); DROP FUNCTION IF EXISTS _st_overlaps(geometry, raster, integer); --- function deprecated +-- function no longer exists +DROP FUNCTION IF EXISTS st_touches(geometry, raster, integer); +DROP FUNCTION IF EXISTS st_touches(raster, geometry, integer); +DROP FUNCTION IF EXISTS st_touches(raster, integer, geometry); DROP FUNCTION IF EXISTS _st_touches(geometry, raster, integer); +DROP FUNCTION IF EXISTS _st_touches(raster, geometry, integer); + +-- function no longer exists +DROP FUNCTION IF EXISTS st_contains(raster, geometry, integer); +DROP FUNCTION IF EXISTS st_contains(raster, integer, geometry); +DROP FUNCTION IF EXISTS st_contains(geometry, raster, integer); +DROP FUNCTION IF EXISTS _st_contains(raster, geometry, integer); +DROP FUNCTION IF EXISTS _st_contains(geometry, raster, integer); -- 2.40.0