From: Bruce Momjian <bruce@momjian.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Josef Grahn <josef.grahn@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Bad behaviour on some geometric operations on degenerate polygons
Date: Sat, 15 Feb 2014 00:07:20 -0500
Message-ID: <20140215050720.GE15047@momjian.us> (raw)
In-Reply-To: <1550.1392440409@sss.pgh.pa.us>
References: <CAMBOBOmnoquwMuEiNABC_BKmHuNiW=6DQybZvM2SQUS=S5TT4g@mail.gmail.com>
<20140215045525.GC15047@momjian.us>
<1550.1392440409@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Sat, Feb 15, 2014 at 12:00:09AM -0500, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > What is odd however, is that we allow _explicit_ creation of zero-radius
> > circles:
>
> > test=> SELECT circle '<(1,1),0>';
> > circle
> > -----------
> > <(1,1),0>
> > (1 row)
>
> > so why do we prevent the conversion of single-point polygons to circles
> > with zero radius? I don't know.
>
> Maybe we should rethink that. What you've done here seems like a kluge.
Yes, it would be much easier to allow the zero-radius circles. The
attached smaller patch allows all the cases to work:
test=> SELECT @@ polygon '((1, 1))';
?column?
----------
(1,1)
(1 row)
test=> SELECT point(polygon '((1, 1))');
point
-------
(1,1)
(1 row)
test=> SELECT circle(polygon '((1, 1))');
circle
-----------
<(1,1),0>
(1 row)
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugsAttachments:geo2.diff (text/x-diff, 1.0K) downloaddiff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.cnew file mode 100644index 0a68be6..e8fbe4e
*** a/src/backend/utils/adt/geo_ops.c
--- b/src/backend/utils/adt/geo_ops.c
*************** poly_circle(PG_FUNCTION_ARGS)
*** 5165,5171 ****
CIRCLE *circle;
int i;
! if (poly->npts < 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot convert empty polygon to circle")));
--- 5165,5171 ----
CIRCLE *circle;
int i;
! if (poly->npts < 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot convert empty polygon to circle")));
*************** poly_circle(PG_FUNCTION_ARGS)
*** 5188,5198 ****
circle->radius += point_dt(&poly->p[i], &circle->center);
circle->radius /= poly->npts;
- if (FPzero(circle->radius))- ereport(ERROR,- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),- errmsg("cannot convert empty polygon to circle")));-
PG_RETURN_CIRCLE_P(circle);
}
--- 5188,5193 ----
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: bruce@momjian.us, tgl@sss.pgh.pa.us, josef.grahn@gmail.com
Subject: Re: Bad behaviour on some geometric operations on degenerate polygons
In-Reply-To: <20140215050720.GE15047@momjian.us>
References: <CAMBOBOmnoquwMuEiNABC_BKmHuNiW=6DQybZvM2SQUS=S5TT4g@mail.gmail.com> <20140215045525.GC15047@momjian.us> <1550.1392440409@sss.pgh.pa.us> <20140215050720.GE15047@momjian.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox