Commit 6dc54f2e authored by Bborie Park's avatar Bborie Park

Raster max extent uses envelope like Geometry. Ticket #2777

git-svn-id: http://svn.osgeo.org/postgis/trunk@12740 b70326c6-7e19-0410-871a-916f4a2858ee
parent e22285d1
......@@ -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
......
......@@ -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);
......
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
......@@ -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||||
......
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
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
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
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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment