Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 423f69a

Browse files
committed
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
1 parent 8457d0b commit 423f69a

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/backend/utils/adt/geo_ops.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -5191,7 +5191,7 @@ poly_circle(PG_FUNCTION_ARGS)
51915191
CIRCLE *circle;
51925192
int i;
51935193

5194-
if (poly->npts < 2)
5194+
if (poly->npts < 1)
51955195
ereport(ERROR,
51965196
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
51975197
errmsg("cannot convert empty polygon to circle")));
@@ -5214,11 +5214,6 @@ poly_circle(PG_FUNCTION_ARGS)
52145214
circle->radius += point_dt(&poly->p[i], &circle->center);
52155215
circle->radius /= poly->npts;
52165216

5217-
if (FPzero(circle->radius))
5218-
ereport(ERROR,
5219-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5220-
errmsg("cannot convert empty polygon to circle")));
5221-
52225217
PG_RETURN_CIRCLE_P(circle);
52235218
}
52245219

0 commit comments

Comments
 (0)