Opened 13 years ago

Closed 17 months ago

#1778 closed defect (wontfix)

ST_CollectionExtract: inconsistent EMPTY results

Reported by: strk Owned by: strk
Priority: medium Milestone: PostGIS Fund Me
Component: postgis Version: 2.0.x
Keywords: Cc:

Description

strk=# select ST_AsEWKT(ST_CollectionExtract('LINESTRING EMPTY', 2));
    st_asewkt     
------------------
 LINESTRING EMPTY
(1 row)

strk=# select ST_AsEWKT(ST_CollectionExtract('GEOMETRYCOLLECTION EMPTY', 2));
       st_asewkt       
-----------------------
 MULTILINESTRING EMPTY
(1 row)

Why is it a _single_ empty in the first case but a _multi_ empty in the second ? How to transform a multi to a simple ? (ST_Homogenize missing)

Attachments (1)

cep.patch (1.0 KB ) - added by pramsey 13 years ago.
Returns all results as multi*

Download all attachments as: .zip

Change History (11)

comment:1 by pramsey, 13 years ago

Resolution: invalid
Status: newclosed

Actually the behaviour is consistent: when passed a non-collection, the function just echoes it back. This is true with both empties and non-empties.

postgis20=# select ST_AsText(ST_CollectionExtract('GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1))', 2));
         st_astext          
----------------------------
 MULTILINESTRING((0 0,1 1))
(1 row)

postgis20=# select ST_AsText(ST_CollectionExtract('LINESTRING(0 0, 1 1)', 2));
      st_astext      
---------------------
 LINESTRING(0 0,1 1)
(1 row)

The return for non-empty collections is always a homogeneous multi-something, even if the input collection has only one member.

in reply to:  1 comment:2 by strk, 13 years ago

Resolution: invalid
Status: closedreopened

Replying to pramsey:

Actually the behaviour is consistent: when passed a non-collection, the function just echoes it back.

Not true. Was changed some time ago to always return the requested type:

=# select ST_AsText(ST_CollectionExtract('POINT(0 0)', 2));
    st_astext
------------------
 LINESTRING EMPTY
(1 row)

See #457

It would be consistent to always return the MULTI* version of the requested type…

by pramsey, 13 years ago

Attachment: cep.patch added

Returns all results as multi*

comment:3 by pramsey, 13 years ago

Not sure I like this improvement entirely, but what the heck.

comment:4 by pramsey, 13 years ago

Milestone: PostGIS 2.0.1PostGIS 2.1.0

Ah, and how I know why I don't like this improvement, it breaks regression (of course, I knew that, but it's more obvious when the regression tests fail, which they do). So this change would change the behaviour of the 2.0 branch. I'm pushing it forward to 2.1 on principle.

comment:5 by pramsey, 13 years ago

Resolution: fixed
Status: reopenedclosed

Changed to always return MULTI* at r9764

comment:6 by pramsey, 13 years ago

Resolution: fixed
Status: closedreopened

…aaand, backed out again at r9766

strk, if you want this you'll have to apply it yourself and fix/change the topology code to match.

comment:7 by pramsey, 13 years ago

Owner: changed from pramsey to strk
Status: reopenednew

comment:8 by robe, 12 years ago

Milestone: PostGIS 2.1.0PostGIS Future

punt

comment:9 by robe, 7 years ago

Milestone: PostGIS FuturePostGIS Fund Me

Milestone renamed

comment:10 by pramsey, 17 months ago

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.