PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ LWGEOM_simplify2d()

Datum LWGEOM_simplify2d ( PG_FUNCTION_ARGS  )

Definition at line 64 of file lwgeom_functions_analytic.c.

65 {
66  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P_COPY(0);
67  double dist = PG_GETARG_FLOAT8(1);
68  GSERIALIZED *result;
69  int type = gserialized_get_type(geom);
70  LWGEOM *in;
71  bool preserve_collapsed = false;
72  int modified = LW_FALSE;
73 
74  /* Can't simplify points! */
75  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
76  PG_RETURN_POINTER(geom);
77 
78  /* Handle optional argument to preserve collapsed features */
79  if ((PG_NARGS() > 2) && (!PG_ARGISNULL(2)))
80  preserve_collapsed = PG_GETARG_BOOL(2);
81 
82  in = lwgeom_from_gserialized(geom);
83 
84  modified = lwgeom_simplify_in_place(in, dist, preserve_collapsed);
85  if (!modified)
86  PG_RETURN_POINTER(geom);
87 
88  if (!in || lwgeom_is_empty(in))
89  PG_RETURN_NULL();
90 
91  result = geometry_serialize(in);
92  PG_RETURN_POINTER(result);
93 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized.c:89
#define LW_FALSE
Definition: liblwgeom.h:108
int lwgeom_simplify_in_place(LWGEOM *igeom, double dist, int preserve_collapsed)
Definition: lwgeom.c:1715
#define MULTIPOINTTYPE
Definition: liblwgeom.h:119
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:116
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:193
type
Definition: ovdump.py:42
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

References geometry_serialize(), gserialized_get_type(), LW_FALSE, lwgeom_from_gserialized(), lwgeom_is_empty(), lwgeom_simplify_in_place(), MULTIPOINTTYPE, POINTTYPE, and ovdump::type.

Here is the call graph for this function: