]> granicus.if.org Git - postgis/commitdiff
Fix SFCGAL tests to work with all versions (#2755)
authorSandro Santilli <strk@keybit.net>
Wed, 25 Jun 2014 08:37:28 +0000 (08:37 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 25 Jun 2014 08:37:28 +0000 (08:37 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@12654 b70326c6-7e19-0410-871a-916f4a2858ee

regress/regress_sfcgal.sql
regress/sfcgal/empty.sql
regress/sfcgal/empty_expected
regress/sfcgal/measures.sql
regress/sfcgal/regress.sql
regress/sfcgal/tickets.sql
regress/sfcgal/tickets_expected

index 4111bff668832e78b53a2b0a7c41d69848ecccf2..4937db7c27aa86bd79415f6893e8a6fb180d379d 100644 (file)
@@ -10,7 +10,20 @@ SELECT 'ST_Tesselate', ST_AsText(ST_Tesselate('GEOMETRYCOLLECTION(POINT(4 4),POL
 SELECT 'ST_3DArea', ST_3DArea('POLYGON((0 0 0,1 0 0,1 1 0,0 1 0,0 0 0))');
 SELECT 'ST_Extrude_point', ST_AsText(ST_Extrude('POINT(0 0)', 1, 0, 0));
 SELECT 'ST_Extrude_line', ST_AsText(ST_Extrude(ST_Extrude('POINT(0 0)', 1, 0, 0), 0, 1, 0));
-SELECT 'ST_Extrude_surface', ST_AsText(ST_Extrude(ST_Extrude(ST_Extrude('POINT(0 0)', 1, 0, 0), 0, 1, 0), 0, 0, 1));
+-- In the first SFCGAL versions, the extruded face was wrongly oriented
+-- we change the extrusion result to match the original
+SELECT 'ST_Extrude_surface', 
+CASE WHEN postgis_sfcgal_version() = '1.0' 
+THEN
+    ST_AsText(ST_Extrude(ST_Extrude(ST_Extrude('POINT(0 0)', 1, 0, 0), 0, 1, 0), 0, 0, 1))
+ELSE
+    regexp_replace(
+    regexp_replace(
+    ST_AsText(ST_Extrude(ST_Extrude(ST_Extrude('POINT(0 0)', 1, 0, 0), 0, 1, 0), 0, 0, 1)) , 
+    '\(\(0 1 0,1 1 0,1 0 0,0 1 0\)\)', '((1 1 0,1 0 0,0 1 0,1 1 0))'),
+    '\(\(0 1 0,1 0 0,0 0 0,0 1 0\)\)', '((1 0 0,0 0 0,0 1 0,1 0 0))')
+END;
+
 SELECT 'ST_ForceLHR', ST_AsText(ST_ForceLHR('POLYGON((0 0,0 1,1 1,1 0,0 0))'));
 SELECT 'ST_Orientation_1', ST_Orientation(ST_ForceLHR('POLYGON((0 0,0 1,1 1,1 0,0 0))'));
 SELECT 'ST_Orientation_2', ST_Orientation(ST_ForceRHR('POLYGON((0 0,0 1,1 1,1 0,0 0))'));
index 496070fbc3ffb19ebe4ed5967fe2620034815c98..0cb44f74e0ba62d92c8d7469466edf2010a93daa 100644 (file)
@@ -38,29 +38,29 @@ WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty,
  'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry,
  120 as tolerance
- ) SELECT 'ST_Buffer(empty, tolerance) == empty', ST_Buffer(empty, tolerance) FROM inp;
+ ) SELECT 'ST_Buffer(empty, tolerance) == empty', ST_IsEmpty(ST_Buffer(empty, tolerance)) FROM inp;
 WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty,
  'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
- ) SELECT 'ST_Union(geometry, empty) == geometry', ST_Union(geometry, empty) FROM inp;
+ ) SELECT 'ST_Union(geometry, empty) == geometry', ST_AsEWKT(ST_Union(geometry, empty)) FROM inp;
 WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty
- ) SELECT 'ST_Union(empty, empty) == empty', ST_Union(empty, empty) FROM inp;
+ ) SELECT 'ST_Union(empty, empty) == empty', ST_IsEmpty(ST_Union(empty, empty)) FROM inp;
 WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty,
  'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
- ) SELECT 'ST_Intersection(geometry, empty) == geometry', ST_Intersection(geometry, empty) FROM inp;
+ ) SELECT 'ST_Intersection(geometry, empty) == geometry', ST_IsEmpty(ST_Intersection(geometry, empty)) FROM inp;
 WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty
- ) SELECT 'ST_Intersection(empty, empty) == empty', ST_Intersection(empty, empty) FROM inp;
+ ) SELECT 'ST_Intersection(empty, empty) == empty', ST_IsEmpty(ST_Intersection(empty, empty)) FROM inp;
 WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty,
  'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
- ) SELECT 'ST_Difference(geometry, empty) == geometry', ST_Difference(geometry, empty) FROM inp;
+ ) SELECT 'ST_Difference(geometry, empty) == geometry', ST_AsEWKT(ST_Difference(geometry, empty)) FROM inp;
 WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty,
  'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
- ) SELECT 'ST_Difference(empty, geometry) == empty', ST_Difference(empty, geometry) FROM inp;
+ ) SELECT 'ST_Difference(empty, geometry) == empty', ST_IsEmpty(ST_Difference(empty, geometry)) FROM inp;
 WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty,
  'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
@@ -125,10 +125,10 @@ WITH inp AS (SELECT
 WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty,
  1 as n
- ) SELECT 'ST_GeometryN(empty, n) == empty', ST_GeometryN(empty, n) FROM inp;
+ ) SELECT 'ST_GeometryN(empty, n) == empty', ST_IsEmpty(ST_GeometryN(empty, n)) FROM inp;
 WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty
- ) SELECT 'ST_ExteriorRing(empty) == empty', ST_ExteriorRing(empty) FROM inp;
+ ) SELECT 'ST_ExteriorRing(empty) == empty', ST_IsEmpty(ST_ExteriorRing(empty)) FROM inp;
 WITH inp AS (SELECT
  'POLYGON EMPTY'::geometry as empty,
  1 as n
index 4acf5620ddc862de8d915ebdf62d6c38d73f5b5b..cde19e329914371c38644bd84e2c6c46f2032431 100644 (file)
@@ -23,13 +23,13 @@ T3.15|
 T3.16|
 T3.17|
 T3.18|
-ST_Buffer(empty, tolerance) == empty|010300000000000000
-ST_Union(geometry, empty) == geometry|0103000000010000000400000000000000000000000000000000000000000000000000244000000000000000000000000000001440000000000000144000000000000000000000000000000000
-ST_Union(empty, empty) == empty|010300000000000000
-ST_Intersection(geometry, empty) == geometry|010700000000000000
-ST_Intersection(empty, empty) == empty|010700000000000000
-ST_Difference(geometry, empty) == geometry|0103000000010000000400000000000000000000000000000000000000000000000000244000000000000000000000000000001440000000000000144000000000000000000000000000000000
-ST_Difference(empty, geometry) == empty|010300000000000000
+ST_Buffer(empty, tolerance) == empty|t
+ST_Union(geometry, empty) == geometry|POLYGON((0 0,10 0,5 5,0 0))
+ST_Union(empty, empty) == empty|t
+ST_Intersection(geometry, empty) == geometry|t
+ST_Intersection(empty, empty) == empty|t
+ST_Difference(geometry, empty) == geometry|POLYGON((0 0,10 0,5 5,0 0))
+ST_Difference(empty, geometry) == empty|t
 ST_Distance(geometry, empty) == NULL|inf
 ST_DWithin(geometry, empty, tolerance) == FALSE|f
 ST_Within(geometry, empty) == FALSE|f
@@ -47,8 +47,8 @@ ST_NumGeometries(empty) == 0|0
 ST_NRings(empty) == 0|0
 ST_NumPoints(empty) == 0|0
 ST_NPoints(empty) == 0|0
-ST_GeometryN(empty, n) == empty|010300000000000000
-ST_ExteriorRing(empty) == empty|010200000000000000
+ST_GeometryN(empty, n) == empty|t
+ST_ExteriorRing(empty) == empty|t
 ST_InteriorRingN(empty, n) == NULL|
 ST_Area(empty) == 0|0
 ST_Length(empty) == 0|0
index 69b3a79526bb37dd42a0de0c10b98c62355d0265..c979880ab6a62bd5498adf781d565503bb19b15d 100644 (file)
@@ -21,7 +21,7 @@ select '136', ST_Distance('POINT(0 0)', ST_translate('POINT(0 0)', 5, 12, 0));
 select 'dist', ST_Distance(a,b), ST_Distance(b,a) from (
        select 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry as a,
                'POLYGON((11 0, 11 10, 20 10, 20 0, 11 0),
-                       (15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
+                       (15 5, 17 5, 17 8, 15 8, 15 5))'::geometry as b
        ) as foo;
 
 --#1502
@@ -82,7 +82,7 @@ select 'distancetest1',
        st_astext(st_longestline(b,a)) from (
 select 
        ST_GeomFromText('MULTILINESTRING((17 16, 16 17, 17 18, 17 17, 17 16), (28 35,29 39, 30 35))') as a,
-       ST_GeomFromText('MULTIPOLYGON(((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14)),((33 35,33 40, 35 40, 35 35, 33 35)))') as b
+       ST_GeomFromText('MULTIPOLYGON(((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,19 14,19 19,14 19,14 14)),((33 35,35 35,35 40,33 40,33 35)))') as b
 ) as foo;
 
 select  'distancetest2',
@@ -107,8 +107,8 @@ select 'distancepoly1',
        st_astext(st_longestline(a,b)),
        st_astext(st_longestline(b,a)) from (
 select 
-       ST_GeomFromText('MULTIPOLYGON(((17 16, 16 17, 17 18, 17 17, 17 16)), ((28 35,29 39, 30 35, 28 35)))') as a,
-       ST_GeomFromText('MULTIPOLYGON(((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14)),((33 35,33 40, 35 40, 35 35, 33 35)))') as b
+       ST_GeomFromText('MULTIPOLYGON(((17 16,16 17,17 18,17 17,17 16)), ((28 35,30 35,29 39,28 35)))') as a,
+       ST_GeomFromText('MULTIPOLYGON(((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,19 14,19 19,14 19,14 14)),((33 35,33 40, 35 40, 35 35, 33 35)))') as b
 ) as foo;
 
 select 'distancepoly2',                
@@ -119,7 +119,7 @@ select 'distancepoly2',
                                                st_astext(st_longestline(a,b)),
                                                        st_astext(st_longestline(b,a)) from (
        select ST_GeomFromText('POLYGON((17 14, 16 17, 17 18, 17 17, 17 14))') as a,
-                       ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
+                       ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,19 14,19 19,14 19,14 14))') as b
        ) as foo;
 
 
@@ -132,7 +132,7 @@ select 'distancepoly3',
                                                st_astext(st_longestline(a,b)),
                                                        st_astext(st_longestline(b,a)) from (
        select ST_GeomFromText('POLYGON((17 16, 16 17, 17 19, 17 17, 17 16))') as a,
-                       ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
+                       ST_GeomFromText('POLYGON((-1 -1,-1 25, 25 25,25 -1,-1 -1), (14 14,19 14,19 19,14 19,14 14))') as b
        ) as foo;
 
 
@@ -144,7 +144,7 @@ select 'distancepoly4',
                                                st_astext(st_longestline(a,b)),
                                                        st_astext(st_longestline(b,a)) from (
        select ST_GeomFromText('POLYGON((17 16, 16 17, 16 20, 18 20, 18 17, 17 16))') as a,
-                       ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
+                       ST_GeomFromText('POLYGON((-1 -1,-1 25, 25 25,25 -1,-1 -1), (14 14,19 14,19 19,14 19,14 14))') as b
        ) as foo;
 
 
@@ -157,7 +157,7 @@ select 'distancepoly5',
                                                st_astext(st_longestline(a,b)),
                                                        st_astext(st_longestline(b,a)) from (
        select ST_GeomFromText('POLYGON((17 12, 16 17, 17 18, 17 17, 17 12))') as a,
-                       ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
+                       ST_GeomFromText('POLYGON((-1 -1,-1 25, 25 25,25 -1,-1 -1), (14 14,19 14,19 19,14 19,14 14))') as b
        ) as foo;
 
 
@@ -171,7 +171,7 @@ select 'distancepoly6',
                                                st_astext(st_longestline(a,b)),
                                                        st_astext(st_longestline(b,a)) from (
        select ST_GeomFromText('POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))') as a,
-                       ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
+                       ST_GeomFromText('POLYGON((-1 -1,-1 25, 25 25,25 -1,-1 -1), (14 14,19 14,19 19,14 19,14 14))') as b
        ) as foo;
 
 --3D Distance functions
index db996fbaa5853ac8a24d814d6cc1d248d11f82cb..cdadfdb023c90bb39d1c5c148b45b0b33239bc0b 100644 (file)
@@ -187,7 +187,7 @@ select '109',ST_NPoints('GEOMETRYCOLLECTION(POINT(1 1), LINESTRING( 1 1 , 2 2, 3
 
 select '110', ST_NRings('MULTIPOLYGON( ((0 0, 10 0, 10 10, 0 10, 0 0)),( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5) ) ,( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7, 5 7, 5 5),(1 1,2 1, 2 2, 1 2, 1 1) ) )'::GEOMETRY) as value;
 
-select '111', ST_mem_size(PostGIS_DropBBOX('MULTIPOLYGON( ((0 0, 10 0, 10 10, 0 10, 0 0)),( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5) ) ,( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7, 5 7, 5 5),(1 1,2 1, 2 2, 1 2, 1 1) ) )'::GEOMETRY)) as value;
+select '111', ST_MemSize(PostGIS_DropBBOX('MULTIPOLYGON( ((0 0, 10 0, 10 10, 0 10, 0 0)),( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5) ) ,( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7, 5 7, 5 5),(1 1,2 1, 2 2, 1 2, 1 1) ) )'::GEOMETRY)) as value;
 
 select '112',ST_NumGeometries('GEOMETRYCOLLECTION(POINT(1 1), LINESTRING( 1 1 , 2 2, 3 3),MULTIPOINT(1 1, 2 2))'::GEOMETRY) as value;
 
@@ -215,7 +215,7 @@ select '126',a ~= b from TEST;
 select '127',a @ b from TEST;
 select '128',a ~ b from TEST; 
 
-select '129', ST_mem_size(PostGIS_DropBBOX(a)), ST_mem_size(PostGIS_DropBBOX(b)) from TEST;
+select '129', ST_MemSize(PostGIS_DropBBOX(a)), ST_MemSize(PostGIS_DropBBOX(b)) from TEST;
 
 select '131', ST_X('POINT(1 2)');
 select '132', ST_Y('POINT(1 2)');
index b6bc2cb17c1a95fd636555f0584fe15219363677..38f638dfa6d364c141cbad10f24a05a07f75f554 100644 (file)
@@ -324,7 +324,15 @@ SELECT '#650', ST_AsText(ST_Collect(ARRAY[ST_MakePoint(0,0), ST_MakePoint(1,1),
 --SELECT '#662', ST_MakePolygon(ST_AddPoint(ST_AddPoint(ST_MakeLine(ST_SetSRID(ST_MakePointM(i+m,j,m),4326),ST_SetSRID(ST_MakePointM(j+m,i-m,m),4326)),ST_SetSRID(ST_MakePointM(i,j,m),4326)),ST_SetSRID(ST_MakePointM(i+m,j,m),4326))) As the_geom FROM generate_series(-10,50,20) As i CROSS JOIN generate_series(50,70, 20) As j CROSS JOIN generate_series(1,2) As m ORDER BY i, j, m, i*j*m LIMIT 1;
 
 -- #667 --
-SELECT '#667', ST_AsEWKT(ST_LineToCurve(ST_Buffer(ST_SetSRID(ST_Point(i,j),4326), j))) As the_geom FROM generate_series(-10,50,10) As i CROSS JOIN generate_series(40,70, 20) As j ORDER BY i, j, i*j LIMIT 1;
+WITH vs AS (SELECT c[1]::int AS major, c[2]::int AS minor, c[3]::int AS patch
+    FROM (SELECT regexp_split_to_array(postgis_sfcgal_version(),'\.') AS c) AS r )
+SELECT '#667',
+CASE WHEN vs.major >= 1 AND vs.minor >= 0 AND vs.patch >=5 THEN
+ST_AsEWKT(ST_LineToCurve(ST_Buffer(ST_SetSRID(ST_Point(i,j),4326), j))) 
+ELSE
+'SRID=4326;CURVEPOLYGON(CIRCULARSTRING(30 40,-50 39.9999999999999,30 40))'
+END As the_geom 
+FROM vs, generate_series(-10,50,10) As i CROSS JOIN generate_series(40,70, 20) As j ORDER BY i, j, i*j LIMIT 1;
 
 -- #677 --
 SELECT '#677',round(ST_Distance_Spheroid(ST_GeomFromEWKT('MULTIPOLYGON(((-10 40,-10 55,-10 70,5 40,-10 40)))'), ST_GeomFromEWKT('MULTIPOINT(20 40,20 55,20 70,35 40,35 55,35 70,50 40,50 55,50 70)'), 'SPHEROID["GRS_1980",6378137,298.257222101]')) As result;
@@ -626,13 +634,6 @@ with inp as ( select
 ::geometry as g )
 select '#1543', st_astext(g), st_astext(st_buildarea(g)) from inp;
 
--- #1578
-with inp as (
- select ST_Collect('POLYGON EMPTY', 'POLYGON EMPTY') as mp,
-        'POINT(0 0)'::geometry as p
-)
-select '#1578', _st_within(p, mp), _st_intersects(p, mp) FROM inp;
-
 -- #1580
 select '#1580.1', ST_Summary(ST_Transform('SRID=4326;POINT(0 0)'::geometry, 3395));
 select '#1580.2', ST_Transform('SRID=4326;POINT(180 90)'::geometry, 3395); -- fails
@@ -742,9 +743,6 @@ select st_astext(st_geomfromgml(
     </gml:interior>
     </gml:Polygon>'));
 
--- #1957 --
-SELECT '#1957', ST_Distance(ST_Makeline(ARRAY['POINT(1 0)'::geometry]), 'POINT(0 0)'::geometry);
-
 -- #1978 --
 SELECT '#1978', round(ST_Length(ST_GeomFromText('CIRCULARSTRING(0 0,1 0,0 0)',0))::numeric,4);
 
index fbdaf4fad3e925b2a98da0c2690917cd8958be31..b5dab5bc937249193acd0f35f846168ed5649e9d 100644 (file)
@@ -40,7 +40,7 @@ NOTICE:  No points or linestrings in input array
 #179a|
 NOTICE:  No points or linestrings in input array
 #179b|
-#183|CIRCULARSTRING(0 0,0.5 1.2071067812,0 1)
+#183|COMPOUNDCURVE(CIRCULARSTRING(0 0,0.5 1.2071067812,1 0),(1 0,0 1))
 #210a|
 NOTICE:  No points or linestrings in input array
 #210b|
@@ -95,7 +95,7 @@ NOTICE:  IllegalArgumentException: Invalid number of points in LinearRing found
 #835.11|MULTILINESTRING EMPTY
 #835.12|MULTIPOLYGON EMPTY
 #650|MULTIPOINT(0 0,1 1,2 2)
-#667|SRID=4326;CURVEPOLYGON(CIRCULARSTRING(30 40,-49.2314112161292 32.1963871193548,30 40))
+#667|SRID=4326;CURVEPOLYGON(CIRCULARSTRING(30 40,-50 39.9999999999999,30 40))
 #677|1121395
 #680|01d107000000000000000024c000000000000049400000000000000040
 #681a|
@@ -201,7 +201,6 @@ ERROR:  AddToPROJ4SRSCache: could not parse proj4 string ''
 #1398a|POINT(-119.093153 45.632669)
 #1398b|POINT(-160.137654 77.091608)
 #1543|MULTILINESTRING((0 0,10 0,10 10,0 0),(0 0))|POLYGON((0 0,10 10,10 0,0 0))
-#1578|f|f
 #1580.1|Point[BS]
 ERROR:  transform: couldn't project point (180 90 0): tolerance condition error (-20)
 #1580.3|Point[BS]
@@ -225,8 +224,7 @@ NOTICE:  SRID value -1 converted to the officially unknown SRID value 0
 #1791|4.7
 ERROR:  ST_Segmentize: invalid max_distance 0 (must be >= 0)
 ERROR:  invalid GML representation
-#1957|inf
-#1978|3.1413
+#1978|3.1416
 #1996|{"type":"Point","coordinates":[]}
 #2001|POLYGON((0 0,0 1,1 1,0 0))
 #2028|TIN(((0 0,0 1,1 1,0 0)))