PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum LWGEOM_SetEffectiveArea ( PG_FUNCTION_ARGS  )

Definition at line 77 of file lwgeom_functions_analytic.c.

References area(), LWGEOM::bbox, dumpnode::geom, geometry_serialize(), gserialized_get_type(), lwgeom_add_bbox(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_set_effective_area(), MULTIPOINTTYPE, and POINTTYPE.

78 {
79  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
80  GSERIALIZED *result;
81  int type = gserialized_get_type(geom);
82  LWGEOM *in;
83  LWGEOM *out;
84  double area=0;
85  int set_area=0;
86 
87  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
88  PG_RETURN_POINTER(geom);
89 
90  if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
91  area = PG_GETARG_FLOAT8(1);
92 
93  if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) )
94  set_area = PG_GETARG_INT32(2);
95 
96  in = lwgeom_from_gserialized(geom);
97 
98  out = lwgeom_set_effective_area(in,set_area, area);
99  if ( ! out ) PG_RETURN_NULL();
100 
101  /* COMPUTE_BBOX TAINTING */
102  if ( in->bbox ) lwgeom_add_bbox(out);
103 
104  result = geometry_serialize(out);
105  lwgeom_free(out);
106  PG_FREE_IF_COPY(geom, 0);
107  PG_RETURN_POINTER(result);
108 }
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:55
GBOX * bbox
Definition: liblwgeom.h:382
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Datum area(PG_FUNCTION_ARGS)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
LWGEOM * lwgeom_set_effective_area(const LWGEOM *igeom, int set_area, double trshld)
LWGEOM * geom
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:599

Here is the call graph for this function: