Ticket #1778 (new defect)

Opened 13 months ago

Last modified 7 weeks ago

ST_CollectionExtract: inconsistent EMPTY results

Reported by: strk Owned by: strk
Priority: medium Milestone: PostGIS Future
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

cep.patch Download (1.0 KB) - added by pramsey 12 months ago.
Returns all results as multi*

Change History

follow-up: ↓ 2   Changed 13 months ago by pramsey

  • status changed from new to closed
  • resolution set to invalid

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   Changed 13 months ago by strk

  • status changed from closed to reopened
  • resolution invalid deleted

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 12 months ago by pramsey

Returns all results as multi*

  Changed 12 months ago by pramsey

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

  Changed 12 months ago by pramsey

  • milestone changed from PostGIS 2.0.1 to PostGIS 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.

  Changed 12 months ago by pramsey

  • status changed from reopened to closed
  • resolution set to fixed

Changed to always return MULTI* at r9764

  Changed 12 months ago by pramsey

  • status changed from closed to reopened
  • resolution fixed deleted

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

  Changed 12 months ago by pramsey

  • owner changed from pramsey to strk
  • status changed from reopened to new

  Changed 7 weeks ago by robe

  • milestone changed from PostGIS 2.1.0 to PostGIS Future

punt

Note: See TracTickets for help on using tickets.