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

Definition at line 43 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, POINTTYPE, and result.

44 {
45  GSERIALIZED *geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
47  int type = gserialized_get_type(geom);
48  LWGEOM *in;
49  LWGEOM *out;
50  double dist;
51 
52  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
53  PG_RETURN_POINTER(geom);
54 
55  dist = PG_GETARG_FLOAT8(1);
56  in = lwgeom_from_gserialized(geom);
57 
58  out = lwgeom_simplify(in, dist);
59  if ( ! out ) PG_RETURN_NULL();
60 
61  /* COMPUTE_BBOX TAINTING */
62  if ( in->bbox ) lwgeom_add_bbox(out);
63 
64  result = geometry_serialize(out);
65  lwgeom_free(out);
66  PG_FREE_IF_COPY(geom, 0);
67  PG_RETURN_POINTER(result);
68 }
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:56
GBOX * bbox
Definition: liblwgeom.h:354
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
char ** result
Definition: liblwgeom.h:218
LWGEOM * geom
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:555
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist)
Definition: lwgeom.c:1478

Here is the call graph for this function: