Bad behaviour on some geometric operations on degenerate polygons

From: Josef Grahn <josef(dot)grahn(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bad behaviour on some geometric operations on degenerate polygons
Date: 2013-10-15 14:03:58
Message-ID: CAMBOBOmnoquwMuEiNABC_BKmHuNiW=6DQybZvM2SQUS=S5TT4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello.

I encountered an unexpected behaviour when doing some geometric operations
on polygons that consist of only one point (or more generally, when all
points in the polygon are identical).

Specifically, taking the center point of such a polygon results in an error
message.

== Code to reproduce ==
SELECT @@ polygon '((1, 1))';

== Expected result ==
(1,1)

== Actual result ==
ERROR: cannot convert empty polygon to circle

The same problem exists when one tries to convert a polygon to a point
using the point() function (presumably because the same code path is
invoked). Ironically, the consequence of this is that the only non-empty
polygon that can *not* be converted to a point, is one that occupy
precisely a single point.

Other operations, such as overlap tests, on the other hand seem to work as
one would expect, which leads me to conclude that handling of degenerate
polygons is meant to function, and that the behaviour of this particular
operation is simply a bug.

This bug report applies to at least PostgreSQL versions 9.1.9 and 9.3.0.
Other versions, I have not tested.

Best Regards,

Josef Grahn

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2013-10-15 14:32:19 Re: Bit String expand bug
Previous Message Andres Freund 2013-10-14 22:28:00 Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist