Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#457 closed defect (fixed)

ST_CollectionExtract returns non-requested type

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


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

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

Attachments (2)

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

Download all attachments as: .zip

Change History (8)

by strk, 14 years ago

Attachment: testcase.patch added

regression testcase (tickets)

comment:1 by pramsey, 14 years ago

Milestone: PostGIS 1.5.1

comment:2 by pramsey, 14 years ago

Milestone: PostGIS 1.5.1PostGIS 1.5.2

comment:3 by nicklas, 14 years ago

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


comment:4 by nicklas, 14 years ago

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.


by nicklas, 14 years ago

Attachment: collectionextract.patch added

only mirrors back non collection cases if type is the requested

comment:5 by pramsey, 14 years ago

Resolution: fixed
Status: newclosed

Committed to 1.5 at r6362, to trunk at r6363.

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

comment:6 by strk, 13 years ago

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.