PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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:96
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)
Definition liblwgeom.h:165
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:166
void ptarray_free(POINTARRAY *pa)
Definition ptarray.c:327
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
Definition lwpoly.c:161
int lwpoly_is_empty(const LWPOLY *poly)
static POINTARRAY * ptarray_chaikin(POINTARRAY *inpts, int preserve_endpoint, int isclosed)
Definition lwchaikins.c:31
POINTARRAY ** rings
Definition liblwgeom.h:519
uint8_t type
Definition liblwgeom.h:522
uint32_t nrings
Definition liblwgeom.h:524
lwflags_t flags
Definition liblwgeom.h:521
int32_t srid
Definition liblwgeom.h:520
uint32_t npoints
Definition liblwgeom.h:427

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: