PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ LWGEOM_SetEffectiveArea()

Datum LWGEOM_SetEffectiveArea ( PG_FUNCTION_ARGS  )

Definition at line 97 of file lwgeom_functions_analytic.c.

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

Referenced by LWGEOM_simplify2d().

98 {
99  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
100  GSERIALIZED *result;
101  int type = gserialized_get_type(geom);
102  LWGEOM *in;
103  LWGEOM *out;
104  double area=0;
105  int set_area=0;
106 
107  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
108  PG_RETURN_POINTER(geom);
109 
110  if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
111  area = PG_GETARG_FLOAT8(1);
112 
113  if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) )
114  set_area = PG_GETARG_INT32(2);
115 
116  in = lwgeom_from_gserialized(geom);
117 
118  out = lwgeom_set_effective_area(in,set_area, area);
119  if ( ! out ) PG_RETURN_NULL();
120 
121  /* COMPUTE_BBOX TAINTING */
122  if ( in->bbox ) lwgeom_add_bbox(out);
123 
124  result = geometry_serialize(out);
125  lwgeom_free(out);
126  PG_FREE_IF_COPY(geom, 0);
127  PG_RETURN_POINTER(result);
128 }
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:86
GBOX * bbox
Definition: liblwgeom.h:400
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:1144
#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:686
type
Definition: ovdump.py:41
Here is the call graph for this function:
Here is the caller graph for this function: