PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_SetEffectiveArea()

Datum LWGEOM_SetEffectiveArea ( PG_FUNCTION_ARGS  )

Definition at line 102 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_line_interpolate_point(), lwgeom_set_effective_area(), MULTIPOINTTYPE, PG_FUNCTION_INFO_V1(), POINTTYPE, and ovdump::type.

Referenced by LWGEOM_simplify2d().

103 {
104  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
105  GSERIALIZED *result;
106  int type = gserialized_get_type(geom);
107  LWGEOM *in;
108  LWGEOM *out;
109  double area=0;
110  int set_area=0;
111 
112  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
113  PG_RETURN_POINTER(geom);
114 
115  if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
116  area = PG_GETARG_FLOAT8(1);
117 
118  if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) )
119  set_area = PG_GETARG_INT32(2);
120 
121  in = lwgeom_from_gserialized(geom);
122 
123  out = lwgeom_set_effective_area(in,set_area, area);
124  if ( ! out ) PG_RETURN_NULL();
125 
126  /* COMPUTE_BBOX TAINTING */
127  if ( in->bbox ) lwgeom_add_bbox(out);
128 
129  result = geometry_serialize(out);
130  lwgeom_free(out);
131  PG_FREE_IF_COPY(geom, 0);
132  PG_RETURN_POINTER(result);
133 }
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:398
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:1099
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
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:85
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:648
type
Definition: ovdump.py:41
Here is the call graph for this function:
Here is the caller graph for this function: