3417 int custom_clip_envelope;
3418 int return_polygons;
3421 if (PG_ARGISNULL(0))
3425 if (PG_ARGISNULL(2))
3427 lwpgerror(
"Tolerance must be a positive number.");
3431 tolerance = PG_GETARG_FLOAT8(2);
3435 lwpgerror(
"Tolerance must be a positive number.");
3440 if (PG_ARGISNULL(3))
3442 lwpgerror(
"return_polygons must be true or false.");
3445 return_polygons = PG_GETARG_BOOL(3);
3448 custom_clip_envelope = !PG_ARGISNULL(1);
3449 if (custom_clip_envelope) {
3450 clip = PG_GETARG_GSERIALIZED_P(1);
3453 lwpgerror(
"Could not determine envelope of clipping geometry.");
3454 PG_FREE_IF_COPY(clip, 1);
3457 PG_FREE_IF_COPY(clip, 1);
3461 input = PG_GETARG_GSERIALIZED_P(0);
3467 lwpgerror(
"Could not read input geometry.");
3468 PG_FREE_IF_COPY(input, 0);
3472 lwgeom_result =
lwgeom_voronoi_diagram(lwgeom_input, custom_clip_envelope ? &clip_envelope : NULL, tolerance, !return_polygons);
3477 lwpgerror(
"Error computing Voronoi diagram.");
3478 PG_FREE_IF_COPY(input, 0);
3482 result = geometry_serialize(lwgeom_result);
3485 PG_FREE_IF_COPY(input, 0);
3486 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.