PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_simplify2d()

Datum LWGEOM_simplify2d ( PG_FUNCTION_ARGS  )

Definition at line 65 of file lwgeom_functions_analytic.c.

66 {
67  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
68  double dist = PG_GETARG_FLOAT8(1);
69  GSERIALIZED *result;
70  int type = gserialized_get_type(geom);
71  LWGEOM *in, *out;
72  bool preserve_collapsed = false;
73 
74  /* Handle optional argument to preserve collapsed features */
75  if ((PG_NARGS() > 2) && (!PG_ARGISNULL(2)))
76  preserve_collapsed = PG_GETARG_BOOL(2);
77 
78  /* Can't simplify points! */
79  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
80  PG_RETURN_POINTER(geom);
81 
82  in = lwgeom_from_gserialized(geom);
83 
84  out = lwgeom_simplify(in, dist, preserve_collapsed);
85  if ( ! out ) PG_RETURN_NULL();
86 
87  /* COMPUTE_BBOX TAINTING */
88  if (in->bbox)
90 
91  result = geometry_serialize(out);
92  lwgeom_free(out);
93  PG_FREE_IF_COPY(geom, 0);
94  PG_RETURN_POINTER(result);
95 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
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:86
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
Definition: lwgeom.c:698
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
Definition: lwgeom.c:1857
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
type
Definition: ovdump.py:41
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
GBOX * bbox
Definition: liblwgeom.h:401

References LWGEOM::bbox, geometry_serialize(), gserialized_get_type(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_refresh_bbox(), lwgeom_simplify(), MULTIPOINTTYPE, POINTTYPE, and ovdump::type.

Here is the call graph for this function: