From: Bborie Park Date: Sun, 6 Jul 2014 18:10:23 +0000 (+0000) Subject: Raster max extent uses envelope like Geometry. Ticket #2777 X-Git-Tag: 2.2.0rc1~1008 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6dc54f2ef7360c60f57d9a3e7329431593549757;p=postgis Raster max extent uses envelope like Geometry. Ticket #2777 git-svn-id: http://svn.osgeo.org/postgis/trunk@12740 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index 2de6d5070..c183f766c 100644 --- a/NEWS +++ b/NEWS @@ -75,9 +75,10 @@ PostGIS 2.2.0 - #2697, invalid GeoJSON Polygon input crashes server process - #2706, ST_DumpPoints of EMPTY geometries crashes server - #2772, Premature memory free in RASTER_getBandPath (ST_BandPath) + - #2777, Raster max extent constraint based upon envelope to behave + like geometry extent - #2803, ST_MapAlgebra handles no userarg and STRICT callback function - * Code refactoring * - Split raster/rt_core/rt_api.c and raster/rt_pg/rt_pg.c files into diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in index e081ef25e..c47947258 100644 --- a/raster/rt_pg/rtpostgis.sql.in +++ b/raster/rt_pg/rtpostgis.sql.in @@ -7057,7 +7057,7 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_extent(rastschema name, rastt AND s.connamespace = n.oid AND s.conrelid = c.oid AND a.attnum = ANY (s.conkey) - AND s.consrc LIKE '%st_coveredby(st_convexhull(%'; + AND s.consrc LIKE '%st_coveredby(st_envelope(%'; $$ LANGUAGE sql STABLE STRICT COST 100; @@ -7077,30 +7077,15 @@ CREATE OR REPLACE FUNCTION _add_raster_constraint_extent(rastschema name, rastta cn := 'enforce_max_extent_' || $3; - sql := 'SELECT st_ashexewkb(st_union(st_convexhull(' + sql := 'SELECT st_ashexewkb(st_envelope(st_collect(st_envelope(' || quote_ident($3) - || '))) FROM ' + || ')))) FROM ' || fqtn; - BEGIN - EXECUTE sql INTO attr; - EXCEPTION WHEN OTHERS THEN - RAISE NOTICE 'Unable to get the extent of the raster column (%:%). Attempting memory efficient (slower) approach', SQLSTATE, SQLERRM; - - sql := 'SELECT st_ashexewkb(st_memunion(st_convexhull(' - || quote_ident($3) - || '))) FROM ' - || fqtn; - BEGIN - EXECUTE sql INTO attr; - EXCEPTION WHEN OTHERS THEN - RAISE NOTICE 'Still unable to get the extent of the raster column (%:%). Cannot add extent constraint', SQLSTATE, SQLERRM; - RETURN FALSE; - END; - END; + EXECUTE sql INTO attr; sql := 'ALTER TABLE ' || fqtn || ' ADD CONSTRAINT ' || quote_ident(cn) - || ' CHECK (st_coveredby(st_convexhull(' + || ' CHECK (st_coveredby(st_envelope(' || quote_ident($3) || '), ''' || attr || '''::geometry))'; RETURN _add_raster_constraint(cn, sql); diff --git a/raster/test/regress/check_raster_columns_expected b/raster/test/regress/check_raster_columns_expected index 2c05c8fcb..659365b6e 100644 --- a/raster/test/regress/check_raster_columns_expected +++ b/raster/test/regress/check_raster_columns_expected @@ -1,23 +1,23 @@ raster_columns t -test_raster_columns|rast|0|1|1|2|2|t|f|1|{8BUI}|{0}|MULTIPOLYGON(((0 0,0 -2,-2 -2,-2 0,0 0)),((3 1,3 -1,1 -1,1 0,0 0,0 2,1 2,1 3,2 3,2 4,4 4,4 2,3 2,3 1))) +test_raster_columns|rast|0|1|1|2|2|t|f|1|{8BUI}|{0}|POLYGON((-2 -2,-2 4,4 4,4 -2,-2 -2)) t test_raster_columns|rast|0|||||f|f|||| t -test_raster_columns|rast|0|||2|2|f|f||||MULTIPOLYGON(((0 0,0 -2,-2 -2,-2 0,0 0)),((3 1,3 -1,1 -1,1 0,0 0,0 2,1 2,1 3,2 3,2 4,4 4,4 2,3 2,3 1))) +test_raster_columns|rast|0|||2|2|f|f||||POLYGON((-2 -2,-2 4,4 4,4 -2,-2 -2)) t -test_raster_columns|rast|0|||2|2|f|f||||MULTIPOLYGON(((0 0,0 -2,-2 -2,-2 0,0 0)),((3 1,3 -1,1 -1,1 0,0 0,0 2,1 2,1 3,2 3,2 4,4 4,4 2,3 2,3 1))) +test_raster_columns|rast|0|||2|2|f|f||||POLYGON((-2 -2,-2 4,4 4,4 -2,-2 -2)) t -test_raster_columns|rast|0|1|1|2|2|t|f|1||{0}|MULTIPOLYGON(((0 0,0 -2,-2 -2,-2 0,0 0)),((3 1,3 -1,1 -1,1 0,0 0,0 2,1 2,1 3,2 3,2 4,4 4,4 2,3 2,3 1))) +test_raster_columns|rast|0|1|1|2|2|t|f|1||{0}|POLYGON((-2 -2,-2 4,4 4,4 -2,-2 -2)) t -test_raster_columns|rast|0|||2|2|t|f|1||{0}|MULTIPOLYGON(((0 0,0 -2,-2 -2,-2 0,0 0)),((3 1,3 -1,1 -1,1 0,0 0,0 2,1 2,1 3,2 3,2 4,4 4,4 2,3 2,3 1))) +test_raster_columns|rast|0|||2|2|t|f|1||{0}|POLYGON((-2 -2,-2 4,4 4,4 -2,-2 -2)) t t t -test_raster_columns|rast|0|1|1|3|3|t|t|1|{8BUI}|{0}|POLYGON((3 0,0 0,0 3,0 6,3 6,6 6,6 3,6 0,3 0)) +test_raster_columns|rast|0|1|1|3|3|t|t|1|{8BUI}|{0}|POLYGON((0 0,0 6,6 6,6 0,0 0)) ERROR: conflicting key value violates exclusion constraint "enforce_spatially_unique_test_raster_columns_rast" ERROR: new row for relation "test_raster_columns" violates check constraint "enforce_coverage_tile_rast" t -test_raster_columns|rast|0|1|1|3|3|t|f|1|{8BUI}|{0}|POLYGON((3 0,0 0,0 3,0 6,3 6,6 6,6 3,6 0,3 0)) +test_raster_columns|rast|0|1|1|3|3|t|f|1|{8BUI}|{0}|POLYGON((0 0,0 6,6 6,6 0,0 0)) t t diff --git a/raster/test/regress/check_raster_overviews_expected b/raster/test/regress/check_raster_overviews_expected index 15f0036f6..93e8968af 100644 --- a/raster/test/regress/check_raster_overviews_expected +++ b/raster/test/regress/check_raster_overviews_expected @@ -2,14 +2,14 @@ raster_overviews test_raster_columns|rast|0|||||f|f|||| test_raster_overviews|rast|0|||||f|f|||| t -test_raster_columns|rast|0|1|1|2|2|t|f|1|{8BUI}|{0}|MULTIPOLYGON(((0 0,0 -2,-2 -2,-2 0,0 0)),((3 1,3 -1,1 -1,1 0,0 0,0 2,1 2,1 3,2 3,2 4,4 4,4 2,3 2,3 1))) +test_raster_columns|rast|0|1|1|2|2|t|f|1|{8BUI}|{0}|POLYGON((-2 -2,-2 4,4 4,4 -2,-2 -2)) test_raster_overviews|rast|0|||||f|f|||| t -test_raster_columns|rast|0|1|1|2|2|t|f|1|{8BUI}|{0}|MULTIPOLYGON(((0 0,0 -2,-2 -2,-2 0,0 0)),((3 1,3 -1,1 -1,1 0,0 0,0 2,1 2,1 3,2 3,2 4,4 4,4 2,3 2,3 1))) +test_raster_columns|rast|0|1|1|2|2|t|f|1|{8BUI}|{0}|POLYGON((-2 -2,-2 4,4 4,4 -2,-2 -2)) test_raster_overviews|rast|0|||||f|f|||| test_raster_overviews|rast|test_raster_columns|rast|1 t -test_raster_columns|rast|0|1|1|2|2|t|f|1|{8BUI}|{0}|MULTIPOLYGON(((0 0,0 -2,-2 -2,-2 0,0 0)),((3 1,3 -1,1 -1,1 0,0 0,0 2,1 2,1 3,2 3,2 4,4 4,4 2,3 2,3 1))) +test_raster_columns|rast|0|1|1|2|2|t|f|1|{8BUI}|{0}|POLYGON((-2 -2,-2 4,4 4,4 -2,-2 -2)) test_raster_overviews|rast|0|||||f|f|||| t test_raster_columns|rast|0|||||f|f|||| diff --git a/raster/test/regress/loader/Basic.select.expected b/raster/test/regress/loader/Basic.select.expected index 9b79c8226..856d81fb0 100644 --- a/raster/test/regress/loader/Basic.select.expected +++ b/raster/test/regress/loader/Basic.select.expected @@ -1,4 +1,4 @@ -0|1.0000000000|-1.0000000000|90|90|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 0,90 0,90 -90,0 -90,0 0)) +0|1.0000000000|-1.0000000000|90|90|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -90,0 0,90 0,90 -90,0 -90)) POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255 POLYGON((89 -89,90 -89,90 -90,89 -90,89 -89))|0 POLYGON((44 -44,45 -44,45 -45,44 -45,44 -44))|0 diff --git a/raster/test/regress/loader/BasicCopy.select.expected b/raster/test/regress/loader/BasicCopy.select.expected index 9b79c8226..856d81fb0 100644 --- a/raster/test/regress/loader/BasicCopy.select.expected +++ b/raster/test/regress/loader/BasicCopy.select.expected @@ -1,4 +1,4 @@ -0|1.0000000000|-1.0000000000|90|90|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 0,90 0,90 -90,0 -90,0 0)) +0|1.0000000000|-1.0000000000|90|90|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -90,0 0,90 0,90 -90,0 -90)) POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255 POLYGON((89 -89,90 -89,90 -90,89 -90,89 -89))|0 POLYGON((44 -44,45 -44,45 -45,44 -45,44 -44))|0 diff --git a/raster/test/regress/loader/BasicOutDB.select.expected b/raster/test/regress/loader/BasicOutDB.select.expected index 949d2b58c..e8622fc42 100644 --- a/raster/test/regress/loader/BasicOutDB.select.expected +++ b/raster/test/regress/loader/BasicOutDB.select.expected @@ -1,4 +1,4 @@ -0|1.0000000000|-1.0000000000|90|90|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{t,t,t}|POLYGON((0 0,90 0,90 -90,0 -90,0 0)) +0|1.0000000000|-1.0000000000|90|90|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{t,t,t}|POLYGON((0 -90,0 0,90 0,90 -90,0 -90)) POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255 POLYGON((89 -89,90 -89,90 -90,89 -90,89 -89))|0 POLYGON((44 -44,45 -44,45 -45,44 -45,44 -44))|0 diff --git a/raster/test/regress/loader/Tiled10x10.select.expected b/raster/test/regress/loader/Tiled10x10.select.expected index ef06f3def..5f882d250 100644 --- a/raster/test/regress/loader/Tiled10x10.select.expected +++ b/raster/test/regress/loader/Tiled10x10.select.expected @@ -1,4 +1,4 @@ -0|1.0000000000|-1.0000000000|10|10|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((90 -80,90 -90,80 -90,70 -90,60 -90,50 -90,40 -90,30 -90,20 -90,10 -90,0 -90,0 -80,0 -70,0 -60,0 -50,0 -40,0 -30,0 -20,0 -10,0 0,10 0,20 0,30 0,40 0,50 0,60 0,70 0,80 0,90 0,90 -10,90 -20,90 -30,90 -40,90 -50,90 -60,90 -70,90 -80)) +0|1.0000000000|-1.0000000000|10|10|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -90,0 0,90 0,90 -90,0 -90)) POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255 POLYGON((0 -80,1 -80,1 -81,0 -81,0 -80))|255 POLYGON((80 -80,81 -80,81 -81,80 -81,80 -80))|255 diff --git a/raster/test/regress/loader/Tiled10x10Copy.select.expected b/raster/test/regress/loader/Tiled10x10Copy.select.expected index ef06f3def..5f882d250 100644 --- a/raster/test/regress/loader/Tiled10x10Copy.select.expected +++ b/raster/test/regress/loader/Tiled10x10Copy.select.expected @@ -1,4 +1,4 @@ -0|1.0000000000|-1.0000000000|10|10|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((90 -80,90 -90,80 -90,70 -90,60 -90,50 -90,40 -90,30 -90,20 -90,10 -90,0 -90,0 -80,0 -70,0 -60,0 -50,0 -40,0 -30,0 -20,0 -10,0 0,10 0,20 0,30 0,40 0,50 0,60 0,70 0,80 0,90 0,90 -10,90 -20,90 -30,90 -40,90 -50,90 -60,90 -70,90 -80)) +0|1.0000000000|-1.0000000000|10|10|t|f|3|{8BUI,8BUI,8BUI}|{NULL,NULL,NULL}|{f,f,f}|POLYGON((0 -90,0 0,90 0,90 -90,0 -90)) POLYGON((0 0,1 0,1 -1,0 -1,0 0))|255 POLYGON((0 -80,1 -80,1 -81,0 -81,0 -80))|255 POLYGON((80 -80,81 -80,81 -81,80 -81,80 -80))|255