PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ 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.

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().

478 {
479  LWDEBUG(2, "Entered lwpoly_set_effective_area");
480  int 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 ocollapse 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 }
int npoints
Definition: liblwgeom.h:371
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
static POINTARRAY * ptarray_set_effective_area(POINTARRAY *inpts, int avoid_collaps, int set_area, double trshld)
#define LW_FAILURE
Definition: liblwgeom.h:79
uint8_t type
Definition: liblwgeom.h:451
POINTARRAY ** rings
Definition: liblwgeom.h:457
int lwpoly_is_empty(const LWPOLY *poly)
Definition: lwpoly.c:445
int nrings
Definition: liblwgeom.h:455
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
int32_t srid
Definition: liblwgeom.h:454
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
Definition: lwpoly.c:161
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
Definition: lwpoly.c:249
uint8_t flags
Definition: liblwgeom.h:452
Here is the call graph for this function:
Here is the caller graph for this function: