PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ptarray_set_effective_area()

static POINTARRAY* ptarray_set_effective_area ( POINTARRAY inpts,
int  avoid_collaps,
int  set_area,
double  trshld 
)
static

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, ovdump::opts, 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  int p;
406  POINT4D pt;
407  EFFECTIVE_AREAS *ea;
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);
415 
416  opts = ptarray_construct_empty(FLAGS_GET_Z(inpts->flags), set_m, inpts->npoints);
417 
418  ptarray_calc_areas(ea,avoid_collaps,set_area,trshld);
419 
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  }
446 
447  return opts;
448 
449 }
void destroy_effectivearea(EFFECTIVE_AREAS *ea)
Definition: effectivearea.c:42
double m
Definition: liblwgeom.h:352
Structure to hold pointarray and it&#39;s arealist.
Definition: effectivearea.h:64
int npoints
Definition: liblwgeom.h:371
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
EFFECTIVE_AREAS * initiate_effectivearea(const POINTARRAY *inpts)
Definition: effectivearea.c:30
POINT4D getPoint4d(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:105
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:369
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
double * res_arealist
Definition: effectivearea.h:68
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
opts
Definition: ovdump.py:44
Here is the call graph for this function:
Here is the caller graph for this function: