Opened 12 years ago

Closed 12 years ago

Last modified 12 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: master
Keywords: Cc:

Description

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);

st_isempty


f

(1 row)

Also see this geos bug which exacerbates the problem: http://trac.osgeo.org/geos/ticket/594

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 by robe, 12 years ago

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:
t

What your bytea resolves to is this:

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

result
------------
POLYGON(())

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

comment:2 by robe, 12 years ago

Milestone: PostGIS 2.1.0PostGIS GEOS

I also checked this on 2.1+

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

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

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

Milestone: PostGIS GEOSPostGIS 2.1.0
Resolution: fixed
Status: newclosed

Done at r10630

comment:5 by strk, 12 years ago

how bad would it be to backport this to 1.5 ?

comment:6 by pramsey, 12 years ago

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 by strk, 12 years ago

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

comment:8 by pramsey, 12 years ago

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

comment:9 by pramsey, 12 years ago

Backed to 2.0 in r10686

Note: See TracTickets for help on using tickets.