PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ LWGEOM_ChaikinSmoothing()

Datum LWGEOM_ChaikinSmoothing ( PG_FUNCTION_ARGS  )

Definition at line 124 of file lwgeom_functions_analytic.c.

125 {
126  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
128  int type = gserialized_get_type(geom);
129  LWGEOM *in;
130  LWGEOM *out;
131  int preserve_endpoints=1;
132  int n_iterations=1;
133 
134  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
135  PG_RETURN_POINTER(geom);
136 
137  if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
138  n_iterations = PG_GETARG_INT32(1);
139 
140  if (n_iterations< 1 || n_iterations>5)
141  elog(ERROR,"Number of iterations must be between 1 and 5 : %s", __func__);
142 
143  if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) )
144  {
145  if(PG_GETARG_BOOL(2))
146  preserve_endpoints = 1;
147  else
148  preserve_endpoints = 0;
149  }
150 
151  in = lwgeom_from_gserialized(geom);
152 
153  out = lwgeom_chaikin(in, n_iterations, preserve_endpoints);
154  if ( ! out ) PG_RETURN_NULL();
155 
156  /* COMPUTE_BBOX TAINTING */
157  if ( in->bbox ) lwgeom_add_bbox(out);
158 
159  result = geometry_serialize(out);
160  lwgeom_free(out);
161  PG_FREE_IF_COPY(geom, 0);
162  PG_RETURN_POINTER(result);
163 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:268
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized.c:118
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1218
#define MULTIPOINTTYPE
Definition: liblwgeom.h:105
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:102
LWGEOM * lwgeom_chaikin(const LWGEOM *igeom, int n_iterations, int preserve_endpoint)
Definition: lwchaikins.c:182
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:695
type
Definition: ovdump.py:42
GBOX * bbox
Definition: liblwgeom.h:458

References LWGEOM::bbox, gserialized_get_type(), lwgeom_add_bbox(), lwgeom_chaikin(), lwgeom_free(), lwgeom_from_gserialized(), MULTIPOINTTYPE, POINTTYPE, result, and ovdump::type.

Here is the call graph for this function: