This allows finding the center of a single-point polygon and converting
it to a point.
Per report from Josef Grahn
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")));
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);
}