PostGIS  2.2.7dev-r@@SVN_REVISION@@
static POINTARRAY* ptarray_set_effective_area ( POINTARRAY inpts,
int  avoid_collaps,
int  set_area,
double  trshld 
)
static

Definition at line 388 of file effectivearea.c.

References destroy_effectivearea(), POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint4d(), initiate_effectivearea(), EFFECTIVE_AREAS::inpts, LW_TRUE, LWDEBUG, POINT4D::m, POINTARRAY::npoints, ptarray_append_point(), ptarray_calc_areas(), ptarray_construct_empty(), and EFFECTIVE_AREAS::res_arealist.

Referenced by lwline_set_effective_area(), and lwpoly_set_effective_area().

389 {
390  LWDEBUG(2, "Entered ptarray_set_effective_area");
391  int p;
392  POINT4D pt;
393  EFFECTIVE_AREAS *ea;
394  POINTARRAY *opts;
395  int set_m;
396  if(set_area)
397  set_m=1;
398  else
399  set_m=FLAGS_GET_M(inpts->flags);
400  ea=initiate_effectivearea(inpts);
401 
402  opts = ptarray_construct_empty(FLAGS_GET_Z(inpts->flags), set_m, inpts->npoints);
403 
404  ptarray_calc_areas(ea,avoid_collaps,set_area,trshld);
405 
406  if(set_area)
407  {
408  /*Only return points with an effective area above the threashold*/
409  for (p=0;p<ea->inpts->npoints;p++)
410  {
411  if(ea->res_arealist[p]>trshld)
412  {
413  pt=getPoint4d(ea->inpts, p);
414  pt.m=ea->res_arealist[p];
415  ptarray_append_point(opts, &pt, LW_TRUE);
416  }
417  }
418  }
419  else
420  {
421  /*Only return points with an effective area above the threashold*/
422  for (p=0;p<ea->inpts->npoints;p++)
423  {
424  if(ea->res_arealist[p]>trshld)
425  {
426  pt=getPoint4d(ea->inpts, p);
427  ptarray_append_point(opts, &pt, LW_TRUE);
428  }
429  }
430  }
432 
433  return opts;
434 
435 }
void destroy_effectivearea(EFFECTIVE_AREAS *ea)
Definition: effectivearea.c:28
double m
Definition: liblwgeom.h:336
Structure to hold pointarray and it's arealist.
Definition: effectivearea.h:50
int npoints
Definition: liblwgeom.h:355
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
void ptarray_calc_areas(EFFECTIVE_AREAS *ea, int avoid_collaps, int set_area, double trshld)
We calculate the effective area for the first time.
const POINTARRAY * inpts
Definition: effectivearea.h:52
EFFECTIVE_AREAS * initiate_effectivearea(const POINTARRAY *inpts)
Definition: effectivearea.c:16
POINT4D getPoint4d(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:216
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_TRUE, then a duplicate point will not be added.
Definition: ptarray.c:156
uint8_t flags
Definition: liblwgeom.h:353
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
double * res_arealist
Definition: effectivearea.h:54
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125

Here is the call graph for this function:

Here is the caller graph for this function: