Opened 14 years ago

Closed 14 years ago

#564 closed task (fixed)

ST_DumpPoints support for Polyhedral Surfaces

Reported by: robe Owned by: colivier
Priority: medium Milestone: PostGIS 2.0.0
Component: postgis Version: master
Keywords: Cc:

Description

I'm guessing this should be an easy fix since ST_Dump works fine for Polyhedral.

ST_DumpPoints gives this error

SELECT ST_GeomFromEWKT(
'SRID=0;PolyhedralSurface( 
((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),  
((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),  ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),  
((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)),  ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) 
)'
Unexpected error while dumping POLYHEDRALSURFACE

Change History (4)

comment:1 by robe, 14 years ago

Typo - I meant

SELECT ST_DumpPoints(ST_GeomFromEWKT(
'PolyhedralSurface( 
((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),  
((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),  ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),  
((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)),  ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) 
)'))

comment:2 by yabo, 14 years ago

Hi,

The problem is that ST_DumpPoints doesn't use the ST_IsCollection function. Here's a patch that fixes the problem and adds some regression tests to ST_IsCollection and ST_DumpPoints for PolyhedralSurface.

Index: postgis/postgis.sql.in.c
===================================================================
--- postgis/postgis.sql.in.c    (revision 5806)
+++ postgis/postgis.sql.in.c    (working copy)
@@ -1943,17 +1943,14 @@
   i integer;
   j integer;
   g geometry;
-  typ text;
   
 BEGIN
   
   RAISE DEBUG '%,%', cur_path, ST_GeometryType(the_geom);
 
-  -- Special case (MULTI* OR GEOMETRYCOLLECTION) : iterate and return the DumpPoints of the geometries
-  SELECT ST_GeometryType(the_geom) INTO typ;
+  -- Special case collections : iterate and return the DumpPoints of the geometries
 
-  -- Dont we have an ST_isMulti ?
-  IF (typ like 'ST_Multi%' OR typ = 'ST_GeometryCollection') THEN
+  IF (ST_IsCollection(the_geom)) THEN
     
     i = 1;
     FOR tmp2 IN SELECT (ST_Dump(the_geom)).* LOOP
Index: regress/iscollection_expected
===================================================================
--- regress/iscollection_expected       (revision 5806)
+++ regress/iscollection_expected       (working copy)
@@ -13,3 +13,6 @@
 empty collection|t
 collection|t
 collection+|t
+empty polyhedralsurface|t
+polyhedralsurface|t
+polyhedralsurface+|t
Index: regress/dumppoints.sql
===================================================================
--- regress/dumppoints.sql      (revision 5806)
+++ regress/dumppoints.sql      (working copy)
@@ -93,6 +93,28 @@
   SELECT (ST_DumpPoints(g.geom)).* 
   FROM
     (SELECT 
+       'POLYHEDRALSURFACE (((
+                0 0 0, 
+                0 0 1, 
+                0 1 1, 
+                0 1 0, 
+                0 0 0
+            )), ((
+                0 0 0, 
+                0 1 0, 
+                1 1 0, 
+                1 0 0, 
+                0 0 0
+            ))
+            )'::geometry AS geom
+    ) AS g
+  ) j;
+
+SELECT path, ST_AsText(geom) 
+FROM (
+  SELECT (ST_DumpPoints(g.geom)).* 
+  FROM
+    (SELECT 
        'GEOMETRYCOLLECTION(
           POINT(99 98), 
           LINESTRING(1 1, 3 3),
Index: regress/dumppoints_expected
===================================================================
--- regress/dumppoints_expected (revision 5806)
+++ regress/dumppoints_expected (working copy)
@@ -35,6 +35,16 @@
 {2,2,2}|POINT(6 8)
 {2,2,3}|POINT(8 8)
 {2,2,4}|POINT(7 6)
+{1,1,1}|POINT(0 0 0)
+{1,1,2}|POINT(0 0 1)
+{1,1,3}|POINT(0 1 1)
+{1,1,4}|POINT(0 1 0)
+{1,1,5}|POINT(0 0 0)
+{2,1,1}|POINT(0 0 0)
+{2,1,2}|POINT(0 1 0)
+{2,1,3}|POINT(1 1 0)
+{2,1,4}|POINT(1 0 0)
+{2,1,5}|POINT(0 0 0)
 {1,1}|POINT(99 98)
 {2,1}|POINT(1 1)
 {2,2}|POINT(3 3)
Index: regress/iscollection.sql
===================================================================
--- regress/iscollection.sql    (revision 5806)
+++ regress/iscollection.sql    (working copy)
@@ -25,4 +25,6 @@
 SELECT 'collection', ST_IsCollection('GEOMETRYCOLLECTION(POINT(0 0))');
 SELECT 'collection+', ST_IsCollection('GEOMETRYCOLLECTION(POINT(0 0), POINT(42 42))');
 
-
+SELECT 'empty polyhedralsurface', ST_IsCollection('POLYHEDRALSURFACE EMPTY');
+SELECT 'polyhedral', ST_IsCollection('POLYHEDRALSURFACE(((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)))');
+SELECT 'polyhedral+', ST_IsCollection('POLYHEDRALSURFACE(((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)))');

comment:3 by colivier, 14 years ago

Owner: changed from pramsey to colivier

comment:4 by colivier, 14 years ago

Resolution: fixed
Status: newclosed

Done as r5830 Thanks again to yabo for the patch ! :)

Note: See TracTickets for help on using tickets.