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

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

46 {
47  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
48  double dist = PG_GETARG_FLOAT8(1);
49  GSERIALIZED *result;
50  int type = gserialized_get_type(geom);
51  LWGEOM *in, *out;
52  bool preserve_collapsed = false;
53 
54  /* Handle optional argument to preserve collapsed features */
55  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
56  preserve_collapsed = true;
57 
58  /* Can't simplify points! */
59  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
60  PG_RETURN_POINTER(geom);
61 
62  in = lwgeom_from_gserialized(geom);
63 
64  out = lwgeom_simplify(in, dist, preserve_collapsed);
65  if ( ! out ) PG_RETURN_NULL();
66 
67  /* COMPUTE_BBOX TAINTING */
68  if ( in->bbox ) lwgeom_add_bbox(out);
69 
70  result = geometry_serialize(out);
71  lwgeom_free(out);
72  PG_FREE_IF_COPY(geom, 0);
73  PG_RETURN_POINTER(result);
74 }
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.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
LWGEOM * geom
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
Definition: lwgeom.c:1558
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: