PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwpoly_filterm()

static LWPOLY* lwpoly_filterm ( LWPOLY poly,
double  min,
double  max,
int  returnm 
)
static

Definition at line 115 of file lwmval.c.

116 {
117  LWDEBUGF(2, "Entered %s", __func__);
118  int i, nrings;
119  LWPOLY *poly_res = lwpoly_construct_empty(poly->srid, FLAGS_GET_Z(poly->flags),returnm * FLAGS_GET_M(poly->flags));
120 
121  nrings = poly->nrings;
122  for( i = 0; i < nrings; i++ )
123  {
124  /* Ret number of points */
125  POINTARRAY *pa = ptarray_filterm(poly->rings[i], min, max,returnm);
126 
127  /* Skip empty rings */
128  if( pa == NULL )
129  continue;
130 
131  if(pa->npoints>=4)
132  {
133  if (lwpoly_add_ring(poly_res, pa) == LW_FAILURE )
134  {
135  LWDEBUG(2, "Unable to add ring to polygon");
136  lwerror("Unable to add ring to polygon");
137  }
138  }
139  else if (i==0)
140  {
141  ptarray_free(pa);
142  lwpoly_free(poly_res);
143  return NULL;
144  }
145  else
146  ptarray_free(pa);
147  }
148  return poly_res;
149 }
#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
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:175
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
Definition: lwpoly.c:161
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static POINTARRAY * ptarray_filterm(POINTARRAY *pa, double min, double max, int returnm)
Definition: lwmval.c:31
POINTARRAY ** rings
Definition: liblwgeom.h:460
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

References LWPOLY::flags, FLAGS_GET_M, FLAGS_GET_Z, LW_FAILURE, LWDEBUG, LWDEBUGF, lwerror(), lwpoly_add_ring(), lwpoly_construct_empty(), lwpoly_free(), POINTARRAY::npoints, LWPOLY::nrings, ptarray_filterm(), ptarray_free(), LWPOLY::rings, and LWPOLY::srid.

Referenced by lwgeom_filter_m_ignore_null().

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