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

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

403 {
404  LWDEBUG(2, "Entered ptarray_set_effective_area");
405  uint32_t p;
406  POINT4D pt;
408  POINTARRAY *opts;
409  int set_m;
410  if(set_area)
411  set_m=1;
412  else
413  set_m=FLAGS_GET_M(inpts->flags);
414  ea=initiate_effectivearea(inpts);
416  opts = ptarray_construct_empty(FLAGS_GET_Z(inpts->flags), set_m, inpts->npoints);
418  ptarray_calc_areas(ea,avoid_collaps,set_area,trshld);
420  if(set_area)
421  {
422  /*Only return points with an effective area above the threashold*/
423  for (p=0;p<ea->inpts->npoints;p++)
424  {
425  if(ea->res_arealist[p]>trshld)
426  {
427  pt=getPoint4d(ea->inpts, p);
428  pt.m=ea->res_arealist[p];
429  ptarray_append_point(opts, &pt, LW_TRUE);
430  }
431  }
432  }
433  else
434  {
435  /*Only return points with an effective area above the threashold*/
436  for (p=0;p<ea->inpts->npoints;p++)
437  {
438  if(ea->res_arealist[p]>trshld)
439  {
440  pt=getPoint4d(ea->inpts, p);
441  ptarray_append_point(opts, &pt, LW_TRUE);
442  }
443  }
444  }
447  return opts;
449 }
void destroy_effectivearea(EFFECTIVE_AREAS *ea)
Definition: effectivearea.c:42
double m
Definition: liblwgeom.h:351
Structure to hold pointarray and it's arealist.
Definition: effectivearea.h:64
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:83
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:66
unsigned int uint32_t
Definition: uthash.h:78
EFFECTIVE_AREAS * initiate_effectivearea(const POINTARRAY *inpts)
Definition: effectivearea.c:30
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
Definition: lwgeom_api.c:96
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_FALSE, then a duplicate point will not be added.
Definition: ptarray.c:156
uint8_t flags
Definition: liblwgeom.h:368
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
double * res_arealist
Definition: effectivearea.h:68
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
uint32_t npoints
Definition: liblwgeom.h:370

Here is the call graph for this function:

Here is the caller graph for this function: