mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
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
This commit is contained in:
parent
8457d0beca
commit
423f69ab64
@ -5191,7 +5191,7 @@ poly_circle(PG_FUNCTION_ARGS)
|
|||||||
CIRCLE *circle;
|
CIRCLE *circle;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (poly->npts < 2)
|
if (poly->npts < 1)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("cannot convert empty polygon to circle")));
|
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 += point_dt(&poly->p[i], &circle->center);
|
||||||
circle->radius /= poly->npts;
|
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);
|
PG_RETURN_CIRCLE_P(circle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user