3310 int custom_clip_envelope;
3311 int return_polygons;
3314 if (PG_ARGISNULL(0))
3318 if (PG_ARGISNULL(2))
3320 lwpgerror(
"Tolerance must be a positive number.");
3324 tolerance = PG_GETARG_FLOAT8(2);
3328 lwpgerror(
"Tolerance must be a positive number.");
3333 if (PG_ARGISNULL(3))
3335 lwpgerror(
"return_polygons must be true or false.");
3338 return_polygons = PG_GETARG_BOOL(3);
3341 custom_clip_envelope = !PG_ARGISNULL(1);
3342 if (custom_clip_envelope) {
3343 clip = PG_GETARG_GSERIALIZED_P(1);
3346 lwpgerror(
"Could not determine envelope of clipping geometry.");
3347 PG_FREE_IF_COPY(clip, 1);
3350 PG_FREE_IF_COPY(clip, 1);
3354 input = PG_GETARG_GSERIALIZED_P(0);
3360 lwpgerror(
"Could not read input geometry.");
3361 PG_FREE_IF_COPY(input, 0);
3365 lwgeom_result =
lwgeom_voronoi_diagram(lwgeom_input, custom_clip_envelope ? &clip_envelope : NULL, tolerance, !return_polygons);
3370 lwpgerror(
"Error computing Voronoi diagram.");
3371 PG_FREE_IF_COPY(input, 0);
3378 PG_FREE_IF_COPY(input, 0);
3379 PG_RETURN_POINTER(result);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *box)
Read the bounding box off a serialization and calculate one if it is not already there.
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.
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)