PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ LWGEOM_simplify2d()

Datum LWGEOM_simplify2d ( PG_FUNCTION_ARGS  )

Definition at line 58 of file lwgeom_functions_analytic.c.

59 {
60  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P_COPY(0);
61  double dist = PG_GETARG_FLOAT8(1);
63  int type = gserialized_get_type(geom);
64  LWGEOM *in;
65  bool preserve_collapsed = false;
66  int modified = LW_FALSE;
67 
68  /* Can't simplify points! */
69  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
70  PG_RETURN_POINTER(geom);
71 
72  /* Handle optional argument to preserve collapsed features */
73  if ((PG_NARGS() > 2) && (!PG_ARGISNULL(2)))
74  preserve_collapsed = PG_GETARG_BOOL(2);
75 
76  in = lwgeom_from_gserialized(geom);
77 
78  modified = lwgeom_simplify_in_place(in, dist, preserve_collapsed);
79  if (!modified)
80  PG_RETURN_POINTER(geom);
81 
82  if (!in || lwgeom_is_empty(in))
83  PG_RETURN_NULL();
84 
85  result = geometry_serialize(in);
86  PG_RETURN_POINTER(result);
87 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:268
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:118
#define LW_FALSE
Definition: liblwgeom.h:94
int lwgeom_simplify_in_place(LWGEOM *igeom, double dist, int preserve_collapsed)
Definition: lwgeom.c:1823
#define MULTIPOINTTYPE
Definition: liblwgeom.h:105
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:102
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:199
type
Definition: ovdump.py:42

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

Here is the call graph for this function: