PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwpoly_chaikin()

static LWPOLY* lwpoly_chaikin ( const LWPOLY ipoly,
int  n_iterations,
int  preserve_endpoint 
)
static

Definition at line 126 of file lwchaikins.c.

127 {
128  uint32_t i;
129  int j;
130  POINTARRAY *pa, *pa_new;
131  LWPOLY *opoly = lwpoly_construct_empty(ipoly->srid, FLAGS_GET_Z(ipoly->flags), FLAGS_GET_M(ipoly->flags));
132 
133  if( lwpoly_is_empty(ipoly) )
134  return opoly;
135  for (i = 0; i < ipoly->nrings; i++)
136  {
137  pa = ipoly->rings[i];
138  for(j=0;j<n_iterations;j++)
139  {
140  pa_new = ptarray_chaikin(pa,preserve_endpoint,LW_TRUE);
141  if(j>0)
142  ptarray_free(pa);
143  pa=pa_new;
144  }
145  if(pa->npoints>=4)
146  {
147  if( lwpoly_add_ring(opoly,pa ) == LW_FAILURE )
148  return NULL;
149  }
150  }
151 
152  opoly->type = ipoly->type;
153 
154  if( lwpoly_is_empty(opoly) )
155  return NULL;
156 
157  return opoly;
158 
159 }
#define LW_FAILURE
Definition: liblwgeom.h:79
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
Definition: lwpoly.c:247
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:328
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
Definition: lwpoly.c:161
int lwpoly_is_empty(const LWPOLY *poly)
Definition: lwpoly.c:418
static POINTARRAY * ptarray_chaikin(POINTARRAY *inpts, int preserve_endpoint, int isclosed)
Definition: lwchaikins.c:31
POINTARRAY ** rings
Definition: liblwgeom.h:460
uint8_t type
Definition: liblwgeom.h:454
uint32_t nrings
Definition: liblwgeom.h:458
uint8_t flags
Definition: liblwgeom.h:455
int32_t srid
Definition: liblwgeom.h:457
uint32_t npoints
Definition: liblwgeom.h:374
unsigned int uint32_t
Definition: uthash.h:78

References LWPOLY::flags, FLAGS_GET_M, FLAGS_GET_Z, LW_FAILURE, LW_TRUE, lwpoly_add_ring(), lwpoly_construct_empty(), lwpoly_is_empty(), POINTARRAY::npoints, LWPOLY::nrings, ptarray_chaikin(), ptarray_free(), LWPOLY::rings, LWPOLY::srid, and LWPOLY::type.

Referenced by lwgeom_chaikin().

Here is the call graph for this function:
Here is the caller graph for this function: