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

◆ lwpoly_set_effective_area()

static LWPOLY * lwpoly_set_effective_area ( const LWPOLY ipoly,
int  set_area,
double  trshld 
)
static

Definition at line 477 of file effectivearea.c.

478{
479 LWDEBUG(2, "Entered lwpoly_set_effective_area");
480 uint32_t i;
481 int set_m;
482 int avoid_collapse=4;
483 if(set_area)
484 set_m=1;
485 else
486 set_m=FLAGS_GET_M(ipoly->flags);
487 LWPOLY *opoly = lwpoly_construct_empty(ipoly->srid, FLAGS_GET_Z(ipoly->flags), set_m);
488
489 if( lwpoly_is_empty(ipoly) )
490 return opoly; /* should we return NULL instead ? */
491
492 for (i = 0; i < ipoly->nrings; i++)
493 {
494 POINTARRAY *pa = ptarray_set_effective_area(ipoly->rings[i],avoid_collapse,set_area,trshld);
495 /* Add ring to simplified polygon */
496 if(pa->npoints>=4)
497 {
498 if( lwpoly_add_ring(opoly,pa ) == LW_FAILURE )
499 return NULL;
500 }
501 /*Inner rings we allow to collapse and then we remove them*/
502 avoid_collapse=0;
503 }
504
505
506 opoly->type = ipoly->type;
507
508 if( lwpoly_is_empty(opoly))
509 return NULL;
510
511 return opoly;
512
513}
static POINTARRAY * ptarray_set_effective_area(POINTARRAY *inpts, int avoid_collaps, int set_area, double trshld)
#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
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
Definition lwpoly.c:161
int lwpoly_is_empty(const LWPOLY *poly)
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
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, LWDEBUG, lwpoly_add_ring(), lwpoly_construct_empty(), lwpoly_is_empty(), POINTARRAY::npoints, LWPOLY::nrings, ptarray_set_effective_area(), LWPOLY::rings, LWPOLY::srid, and LWPOLY::type.

Referenced by lwgeom_set_effective_area().

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