2502 int custom_clip_envelope;
2503 int return_polygons;
2506 if (PG_ARGISNULL(0))
2510 if (PG_ARGISNULL(2))
2512 lwpgerror(
"Tolerance must be a positive number.");
2516 tolerance = PG_GETARG_FLOAT8(2);
2520 lwpgerror(
"Tolerance must be a positive number.");
2525 if (PG_ARGISNULL(3))
2527 lwpgerror(
"return_polygons must be true or false.");
2530 return_polygons = PG_GETARG_BOOL(3);
2533 custom_clip_envelope = !PG_ARGISNULL(1);
2534 if (custom_clip_envelope) {
2535 clip = PG_GETARG_GSERIALIZED_P(1);
2538 lwpgerror(
"Could not determine envelope of clipping geometry.");
2539 PG_FREE_IF_COPY(clip, 1);
2542 PG_FREE_IF_COPY(clip, 1);
2546 input = PG_GETARG_GSERIALIZED_P(0);
2552 lwpgerror(
"Could not read input geometry.");
2553 PG_FREE_IF_COPY(input, 0);
2557 lwgeom_result =
lwgeom_voronoi_diagram(lwgeom_input, custom_clip_envelope ? &clip_envelope : NULL, tolerance, !return_polygons);
2562 lwpgerror(
"Error computing Voronoi diagram.");
2563 PG_FREE_IF_COPY(input, 0);
2567 result = geometry_serialize(lwgeom_result);
2570 PG_FREE_IF_COPY(input, 0);
2571 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.