]> granicus.if.org Git - postgis/commitdiff
Fixed ST_Polygon regression tests to properly handle different GEOS
authorBborie Park <bkpark at ucdavis.edu>
Tue, 17 Jul 2012 22:38:03 +0000 (22:38 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 17 Jul 2012 22:38:03 +0000 (22:38 +0000)
versions

git-svn-id: http://svn.osgeo.org/postgis/trunk@10069 b70326c6-7e19-0410-871a-916f4a2858ee

raster/test/regress/rt_polygon.sql
raster/test/regress/rt_polygon_expected

index 46b1ee605b38b5033f520a4591c0281fe1e8ecb9..78ba411806d60bbfe12f38cc673cf2916f35c324 100644 (file)
@@ -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;
index fac1464fffd243de608ce313b3d30c704679682e..3d2628a5eeae23f76e337f2043f8b877aeacb9d8 100644 (file)
@@ -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