PostGIS  2.2.7dev-r@@SVN_REVISION@@
static LWPOLY* lwpoly_set_effective_area ( const LWPOLY ipoly,
int  set_area,
double  trshld 
)
static

Definition at line 463 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().

464 {
465  LWDEBUG(2, "Entered lwpoly_set_effective_area");
466  int i;
467  int set_m;
468  int avoid_collapse=4;
469  if(set_area)
470  set_m=1;
471  else
472  set_m=FLAGS_GET_M(ipoly->flags);
473  LWPOLY *opoly = lwpoly_construct_empty(ipoly->srid, FLAGS_GET_Z(ipoly->flags), set_m);
474 
475  if( lwpoly_is_empty(ipoly) )
476  return opoly; /* should we return NULL instead ? */
477 
478  for (i = 0; i < ipoly->nrings; i++)
479  {
480  POINTARRAY *pa = ptarray_set_effective_area(ipoly->rings[i],avoid_collapse,set_area,trshld);
481  /* Add ring to simplified polygon */
482  if(pa->npoints>=4)
483  {
484  if( lwpoly_add_ring(opoly,pa ) == LW_FAILURE )
485  return NULL;
486  }
487  /*Inner rings we allow to ocollapse and then we remove them*/
488  avoid_collapse=0;
489  }
490 
491 
492  opoly->type = ipoly->type;
493 
494  if( lwpoly_is_empty(opoly) )
495  return NULL;
496 
497  return opoly;
498 
499 }
int npoints
Definition: liblwgeom.h:355
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
static POINTARRAY * ptarray_set_effective_area(POINTARRAY *inpts, int avoid_collaps, int set_area, double trshld)
#define LW_FAILURE
Definition: liblwgeom.h:64
uint8_t type
Definition: liblwgeom.h:435
POINTARRAY ** rings
Definition: liblwgeom.h:441
int lwpoly_is_empty(const LWPOLY *poly)
Definition: lwpoly.c:332
int nrings
Definition: liblwgeom.h:439
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
int32_t srid
Definition: liblwgeom.h:438
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
Definition: lwpoly.c:66
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
Definition: lwpoly.c:154
uint8_t flags
Definition: liblwgeom.h:436

Here is the call graph for this function:

Here is the caller graph for this function: