From: Bruce Momjian Date: Mon, 24 Feb 2014 17:24:00 +0000 (-0500) Subject: Allow single-point polygons to be converted to circles X-Git-Tag: REL9_4_BETA1~427 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=423f69ab64a6e51fbdd97a83c1dc55d68ca6190d;p=thirdparty%2Fpostgresql.git Allow single-point polygons to be converted to circles This allows finding the center of a single-point polygon and converting it to a point. Per report from Josef Grahn --- diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index f267920649a..72cb4e991fc 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -5191,7 +5191,7 @@ poly_circle(PG_FUNCTION_ARGS) CIRCLE *circle; int i; - if (poly->npts < 2) + if (poly->npts < 1) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("cannot convert empty polygon to circle"))); @@ -5214,11 +5214,6 @@ poly_circle(PG_FUNCTION_ARGS) 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); }