Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#2015 closed defect (fixed)

ST_IsEmpty('POLYGON(EMPTY)') returns False

Reported by: cdestigter Owned by: pramsey
Priority: medium Milestone: PostGIS 2.1.0
Component: postgis Version: trunk
Keywords: Cc:


Firstly, I used the wkb for POLYGON(EMPTY), since postgis' wkt parser appears to cast a lot of things to GEOMETRYCOLLECTION EMPTY, losing type information.

But shouldn't this return True?

# select st_isempty('01030000000100000000000000'::geometry);



(1 row)

Also see this geos bug which exacerbates the problem:

POSTGIS="2.1.0SVN r10262" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.6"

Change History (9)

comment:1 Changed 6 years ago by robe

Are you sure you typed POLYGON(EMPTY). That isn't valid. In fact I get a parse error when I try to cast that to a geometry.

An empty polygon is this:

SELECT ST_IsEmpty('POLYGON EMPTY'::geometry);

Which gives:

What your bytea resolves to is this:

select st_AsEWKT('01030000000100000000000000'::geometry) As result; 


Which I'm not quite sure what to call that.

comment:2 Changed 6 years ago by robe

Milestone: PostGIS 2.1.0PostGIS GEOS

I also checked this on 2.1+


Comes back as POLYGON EMPTY. We stopped throwing out this info at 2.0. So you should be fine to use that. So your issue might be a pure GEOS and possibly GEOS with django.

comment:3 Changed 6 years ago by pramsey

This isn't a GEOS issue (or, maybe GEOS has a similar WKB interpretation issue), but anyway, I've decided to treat "polygon with a zero vertex ring" as "empty", in the same way "polygon with no rings" is empty. So the example query above will return true. As a side effect, you won't be able to round-trip WKB of the form 01030000000100000000000000. Instead if you put in 01030000000100000000000000 (polygon with one empty ring) you'll get out 010300000000000000 (polygon with no rings).

comment:4 Changed 6 years ago by pramsey

Milestone: PostGIS GEOSPostGIS 2.1.0
Resolution: fixed
Status: newclosed

Done at r10630

comment:5 Changed 6 years ago by strk

how bad would it be to backport this to 1.5 ?

comment:6 Changed 6 years ago by pramsey

It's the old WKB handling code, so fairly un-fun. Not sure what other issues one might run into. What's the benefit?

comment:7 Changed 6 years ago by strk

Sorry I meant 2.0.2 . No unfun things in PostGIS day !

comment:8 Changed 6 years ago by pramsey

It's a change in behaviour, but not an unreasonable one, I don't think. Scary WKB scares me :)

comment:9 Changed 6 years ago by pramsey

Backed to 2.0 in r10686

Note: See TracTickets for help on using tickets.