PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_ChaikinSmoothing()

Datum LWGEOM_ChaikinSmoothing ( PG_FUNCTION_ARGS  )

Definition at line 132 of file lwgeom_functions_analytic.c.

133 {
134  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
135  GSERIALIZED *result;
136  int type = gserialized_get_type(geom);
137  LWGEOM *in;
138  LWGEOM *out;
139  int preserve_endpoints=1;
140  int n_iterations=1;
141 
142  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
143  PG_RETURN_POINTER(geom);
144 
145  if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
146  n_iterations = PG_GETARG_INT32(1);
147 
148  if (n_iterations< 1 || n_iterations>5)
149  elog(ERROR,"Number of iterations must be between 1 and 5 : %s", __func__);
150 
151  if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) )
152  {
153  if(PG_GETARG_BOOL(2))
154  preserve_endpoints = 1;
155  else
156  preserve_endpoints = 0;
157  }
158 
159  in = lwgeom_from_gserialized(geom);
160 
161  out = lwgeom_chaikin(in, n_iterations, preserve_endpoints);
162  if ( ! out ) PG_RETURN_NULL();
163 
164  /* COMPUTE_BBOX TAINTING */
165  if ( in->bbox ) lwgeom_add_bbox(out);
166 
167  result = geometry_serialize(out);
168  lwgeom_free(out);
169  PG_FREE_IF_COPY(geom, 0);
170  PG_RETURN_POINTER(result);
171 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: g_serialized.c:86
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
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:686
type
Definition: ovdump.py:41
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
GBOX * bbox
Definition: liblwgeom.h:401

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

Here is the call graph for this function: