3486 int custom_clip_envelope;
3487 int return_polygons;
3490 if (PG_ARGISNULL(0))
3494 if (PG_ARGISNULL(2))
3496 lwpgerror(
"Tolerance must be a positive number.");
3500 tolerance = PG_GETARG_FLOAT8(2);
3504 lwpgerror(
"Tolerance must be a positive number.");
3509 if (PG_ARGISNULL(3))
3511 lwpgerror(
"return_polygons must be true or false.");
3514 return_polygons = PG_GETARG_BOOL(3);
3517 custom_clip_envelope = !PG_ARGISNULL(1);
3518 if (custom_clip_envelope) {
3519 clip = PG_GETARG_GSERIALIZED_P(1);
3522 lwpgerror(
"Could not determine envelope of clipping geometry.");
3523 PG_FREE_IF_COPY(clip, 1);
3526 PG_FREE_IF_COPY(clip, 1);
3530 input = PG_GETARG_GSERIALIZED_P(0);
3536 lwpgerror(
"Could not read input geometry.");
3537 PG_FREE_IF_COPY(input, 0);
3541 lwgeom_result =
lwgeom_voronoi_diagram(lwgeom_input, custom_clip_envelope ? &clip_envelope : NULL, tolerance, !return_polygons);
3546 lwpgerror(
"Error computing Voronoi diagram.");
3547 PG_FREE_IF_COPY(input, 0);
3551 result = geometry_serialize(lwgeom_result);
3554 PG_FREE_IF_COPY(input, 0);
3555 PG_RETURN_POINTER(
result);
char result[OUT_DOUBLE_BUFFER_SIZE]
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Read the box from the GSERIALIZED or calculate it if necessary.
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
LWGEOM * lwgeom_voronoi_diagram(const LWGEOM *g, const GBOX *env, double tolerance, int output_edges)
Take vertices of a geometry and build the Voronoi diagram.