Opened 8 years ago

Last modified 2 years ago

#1778 new defect

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 7 years ago.
Returns all results as multi*

Download all attachments as: .zip

Change History (10)

comment:1 Changed 8 years ago by pramsey

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.

comment:2 in reply to:  1 Changed 8 years ago by strk

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...

Changed 7 years ago by pramsey

Attachment: cep.patch added

Returns all results as multi*

comment:3 Changed 7 years ago by pramsey

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

comment:4 Changed 7 years ago by pramsey

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 Changed 7 years ago by pramsey

Resolution: fixed
Status: reopenedclosed

Changed to always return MULTI* at r9764

comment:6 Changed 7 years ago by pramsey

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 Changed 7 years ago by pramsey

Owner: changed from pramsey to strk
Status: reopenednew

comment:8 Changed 7 years ago by robe

Milestone: PostGIS 2.1.0PostGIS Future

punt

comment:9 Changed 2 years ago by robe

Milestone: PostGIS FuturePostGIS Fund Me

Milestone renamed

Note: See TracTickets for help on using tickets.