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

Definition at line 67 of file lwgeom_functions_analytic.c.

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

68 {
69  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
70  double dist = PG_GETARG_FLOAT8(1);
71  GSERIALIZED *result;
72  int type = gserialized_get_type(geom);
73  LWGEOM *in, *out;
74  bool preserve_collapsed = false;
75 
76  /* Handle optional argument to preserve collapsed features */
77  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
78  preserve_collapsed = true;
79 
80  /* Can't simplify points! */
81  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
82  PG_RETURN_POINTER(geom);
83 
84  in = lwgeom_from_gserialized(geom);
85 
86  out = lwgeom_simplify(in, dist, preserve_collapsed);
87  if ( ! out ) PG_RETURN_NULL();
88 
89  /* COMPUTE_BBOX TAINTING */
90  if ( in->bbox ) lwgeom_add_bbox(out);
91 
92  result = geometry_serialize(out);
93  lwgeom_free(out);
94  PG_FREE_IF_COPY(geom, 0);
95  PG_RETURN_POINTER(result);
96 }
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.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
LWGEOM * geom
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
Definition: lwgeom.c:1571
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: