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

Definition at line 99 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.

100 {
101  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
102  GSERIALIZED *result;
103  int type = gserialized_get_type(geom);
104  LWGEOM *in;
105  LWGEOM *out;
106  double area=0;
107  int set_area=0;
108 
109  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
110  PG_RETURN_POINTER(geom);
111 
112  if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
113  area = PG_GETARG_FLOAT8(1);
114 
115  if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) )
116  set_area = PG_GETARG_INT32(2);
117 
118  in = lwgeom_from_gserialized(geom);
119 
120  out = lwgeom_set_effective_area(in,set_area, area);
121  if ( ! out ) PG_RETURN_NULL();
122 
123  /* COMPUTE_BBOX TAINTING */
124  if ( in->bbox ) lwgeom_add_bbox(out);
125 
126  result = geometry_serialize(out);
127  lwgeom_free(out);
128  PG_FREE_IF_COPY(geom, 0);
129  PG_RETURN_POINTER(result);
130 }
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:69
GBOX * bbox
Definition: liblwgeom.h:397
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:1063
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
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:84
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:612

Here is the call graph for this function: