From: Bborie Park Date: Tue, 17 Jul 2012 22:38:03 +0000 (+0000) Subject: Fixed ST_Polygon regression tests to properly handle different GEOS X-Git-Tag: 2.1.0beta2~791 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=856ff19edbbb9de53a4d82e353c803851b6ffb74;p=postgis Fixed ST_Polygon regression tests to properly handle different GEOS versions git-svn-id: http://svn.osgeo.org/postgis/trunk@10069 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/test/regress/rt_polygon.sql b/raster/test/regress/rt_polygon.sql index 46b1ee605..78ba41180 100644 --- a/raster/test/regress/rt_polygon.sql +++ b/raster/test/regress/rt_polygon.sql @@ -1,5 +1,7 @@ -DROP TABLE IF EXISTS raster_surface; -CREATE TABLE raster_surface ( +SET client_min_messages TO warning; + +DROP TABLE IF EXISTS raster_polygon; +CREATE TABLE raster_polygon ( rast raster ); CREATE OR REPLACE FUNCTION make_test_raster() @@ -15,7 +17,7 @@ CREATE OR REPLACE FUNCTION make_test_raster() rast := ST_MakeEmptyRaster(width, height, 0, 0, 1, -1, 0, 0, 0); rast := ST_AddBand(rast, 1, '32BUI', 1, 0); - INSERT INTO raster_surface VALUES (rast); + INSERT INTO raster_polygon VALUES (rast); RETURN; END; @@ -23,22 +25,27 @@ CREATE OR REPLACE FUNCTION make_test_raster() SELECT make_test_raster(); DROP FUNCTION make_test_raster(); +CREATE OR REPLACE FUNCTION temp_geos_version() + RETURNS float + AS $$ SELECT ((regexp_matches(split_part(postgis_geos_version(), '-', 1), '^([[:digit:]]+\.[[:digit:]]+)')))[1]::float $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + SELECT - ST_AsText(ST_BandSurface(rast)) -FROM raster_surface; + ST_AsText(ST_Polygon(rast)) = 'MULTIPOLYGON(((0 0,0 -5,5 -5,5 0,0 0)))' +FROM raster_polygon; SELECT - ST_AsText(ST_BandSurface(rast)) + ST_AsText(ST_Polygon(rast)) = 'MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0)))' FROM ( SELECT ST_SetValue( rast, 1, 1, 1, 0 ) AS rast - FROM raster_surface + FROM raster_polygon ) foo; SELECT - ST_AsText(ST_BandSurface(rast)) + ST_AsText(ST_Polygon(rast)) = 'MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0),(1 -1,1 -2,2 -2,2 -1,1 -1)))' FROM ( SELECT ST_SetValue( @@ -47,11 +54,15 @@ FROM ( ), 1, 2, 2, 0 ) AS rast - FROM raster_surface + FROM raster_polygon ) foo; SELECT - ST_AsText(ST_BandSurface(rast)) + CASE + WHEN temp_geos_version() >= 3.3 + THEN ST_AsText(ST_Polygon(rast)) = 'MULTIPOLYGON(((1 -1,1 0,5 0,5 -5,4 -5,0 -5,0 -1,1 -1),(1 -1,1 -2,2 -2,2 -1,1 -1),(2 -2,2 -3,3 -3,3 -2,2 -2)))' + ELSE ST_AsText(ST_Polygon(rast)) = 'MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0),(1 -1,1 -2,2 -2,2 -3,3 -3,3 -2,2 -2,2 -1,1 -1)))' + END FROM ( SELECT ST_SetValue( @@ -63,11 +74,15 @@ FROM ( ), 1, 3, 3, 0 ) AS rast - FROM raster_surface + FROM raster_polygon ) foo; SELECT - ST_AsText(ST_BandSurface(rast)) + CASE + WHEN temp_geos_version() >= 3.3 + THEN ST_AsText(ST_Polygon(rast)) = 'MULTIPOLYGON(((1 -1,1 0,5 0,5 -5,4 -5,0 -5,0 -1,1 -1),(1 -1,1 -2,2 -2,2 -1,1 -1),(2 -2,2 -3,3 -3,3 -2,2 -2),(3 -3,3 -4,4 -4,4 -3,3 -3)))' + ELSE ST_AsText(ST_Polygon(rast)) = 'MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0),(1 -1,1 -2,2 -2,2 -3,3 -3,3 -4,4 -4,4 -3,3 -3,3 -2,2 -2,2 -1,1 -1)))' + END FROM ( SELECT ST_SetValue( @@ -82,11 +97,11 @@ FROM ( ), 1, 4, 4, 0 ) AS rast - FROM raster_surface + FROM raster_polygon ) foo; SELECT - ST_AsText(ST_BandSurface(rast)) + ST_AsText(ST_Polygon(rast)) = 'MULTIPOLYGON(((4 -4,4 -5,0 -5,0 -1,1 -1,1 -2,2 -2,2 -3,3 -3,3 -4,4 -4)),((1 -1,1 0,5 0,5 -4,4 -4,4 -3,3 -3,3 -2,2 -2,2 -1,1 -1)))' FROM ( SELECT ST_SetValue( @@ -104,11 +119,11 @@ FROM ( ), 1, 5, 5, 0 ) AS rast - FROM raster_surface + FROM raster_polygon ) foo; SELECT - ST_AsText(ST_BandSurface(rast)) + ST_AsText(ST_Polygon(rast)) = 'MULTIPOLYGON(((1 -4,2 -4,2 -3,3 -3,3 -4,4 -4,4 -5,3 -5,1 -5,1 -4)),((1 -4,0 -4,0 -1,1 -1,1 -2,2 -2,2 -3,1 -3,1 -4)),((3 -2,4 -2,4 -1,5 -1,5 -4,4 -4,4 -3,3 -3,3 -2)),((3 -2,2 -2,2 -1,1 -1,1 0,4 0,4 -1,3 -1,3 -2)))' FROM ( SELECT ST_SetValue( @@ -138,7 +153,8 @@ FROM ( ), 1, 1, 5, 0 ) AS rast - FROM raster_surface + FROM raster_polygon ) foo; -DROP TABLE IF EXISTS raster_surface; +DROP FUNCTION temp_geos_version(); +DROP TABLE IF EXISTS raster_polygon; diff --git a/raster/test/regress/rt_polygon_expected b/raster/test/regress/rt_polygon_expected index fac1464ff..3d2628a5e 100644 --- a/raster/test/regress/rt_polygon_expected +++ b/raster/test/regress/rt_polygon_expected @@ -1,8 +1,7 @@ -NOTICE: table "raster_surface" does not exist, skipping -MULTIPOLYGON(((0 0,0 -5,5 -5,5 0,0 0))) -MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0))) -MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0),(1 -1,1 -2,2 -2,2 -1,1 -1))) -MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0),(1 -1,1 -2,2 -2,2 -3,3 -3,3 -2,2 -2,2 -1,1 -1))) -MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0),(1 -1,1 -2,2 -2,2 -3,3 -3,3 -4,4 -4,4 -3,3 -3,3 -2,2 -2,2 -1,1 -1))) -MULTIPOLYGON(((4 -4,4 -5,0 -5,0 -1,1 -1,1 -2,2 -2,2 -3,3 -3,3 -4,4 -4)),((1 -1,1 0,5 0,5 -4,4 -4,4 -3,3 -3,3 -2,2 -2,2 -1,1 -1))) -MULTIPOLYGON(((1 -4,2 -4,2 -3,3 -3,3 -4,4 -4,4 -5,3 -5,1 -5,1 -4)),((1 -4,0 -4,0 -1,1 -1,1 -2,2 -2,2 -3,1 -3,1 -4)),((3 -2,4 -2,4 -1,5 -1,5 -4,4 -4,4 -3,3 -3,3 -2)),((3 -2,2 -2,2 -1,1 -1,1 0,4 0,4 -1,3 -1,3 -2))) +t +t +t +t +t +t +t