Ticket #457 (closed defect: fixed)

Opened 3 years ago

Last modified 17 months ago

ST_CollectionExtract returns non-requested type

Reported by: strk Owned by: pramsey
Priority: medium Milestone: PostGIS 1.5.3
Component: postgis Version: trunk
Keywords: history Cc:

Description

strk=# select st_astext(ST_CollectionExtract('POINT(0 0)', 2));
 st_astext
------------
 POINT(0 0)

strk=# select st_astext(ST_CollectionExtract('POINT(0 0)', 3));
 st_astext  
------------
 POINT(0 0)

Attachments

testcase.patch Download (1.8 KB) - added by strk 3 years ago.
regression testcase (tickets)
collectionextract.patch Download (1.0 KB) - added by nicklas 3 years ago.
only mirrors back non collection cases if type is the requested

Change History

Changed 3 years ago by strk

regression testcase (tickets)

Changed 3 years ago by pramsey

  • milestone set to PostGIS 1.5.1

Changed 3 years ago by pramsey

  • milestone changed from PostGIS 1.5.1 to PostGIS 1.5.2

Changed 3 years ago by nicklas

It looks like this behavior is intended from the comment in the end of lwgeom_functions_basic.c:

/* Mirror non-collections right back */

But I agree that this is no good.

As the documentation is written now, it should definitly give an error message if the inputed geometry is not a collection, but it would also make sense as in the testcase.patch, the inputed geometry is mirrored if and only if it is of the type that is asked for. But then that should be reflected in the documentation to.

I can do the changes if someone decides which way to go

/Nicklas

Changed 3 years ago by nicklas

I add a patch that should give the results expected in testcase.patch So it should return the asked for type even if it is not in a collection.

But I have done nothing about the documentation.

If we go this way the function name is a little misleading. It maybe should have been something like ST_TypeExtract instead. But that is nothing for a minor release and I guess that is no big deal.

Or should we give an error message instead if function is feed with else than collection.

Or maybe, always return an empty collection when inputed geometry is not collection with a notice?

But it might be quite useful to just get everything of the asked for type even if it is no collection.

/Nicklas

Changed 3 years ago by nicklas

only mirrors back non collection cases if type is the requested

Changed 2 years ago by pramsey

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

Committed to 1.5 at r6362, to trunk at r6363.

Rather than returning EMPTY on type-misses, I return NULL. Otherwise as submitted.

Changed 17 months ago by strk

  • keywords history added

As of r8720 (2.0.0) we went back to returning (typed) empty. See #835.

Note: See TracTickets for help on using tickets.