PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_simplify2d()

Datum LWGEOM_simplify2d ( PG_FUNCTION_ARGS  )

Definition at line 66 of file lwgeom_functions_analytic.c.

References LWGEOM::bbox, dumpnode::geom, geometry_serialize(), gserialized_get_type(), lwgeom_add_bbox(), lwgeom_drop_bbox(), lwgeom_free(), lwgeom_from_gserialized(), LWGEOM_SetEffectiveArea(), lwgeom_simplify(), MULTIPOINTTYPE, PG_FUNCTION_INFO_V1(), POINTTYPE, and ovdump::type.

67 {
68  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
69  double dist = PG_GETARG_FLOAT8(1);
70  GSERIALIZED *result;
71  int type = gserialized_get_type(geom);
72  LWGEOM *in, *out;
73  bool preserve_collapsed = false;
74 
75  /* Handle optional argument to preserve collapsed features */
76  if ((PG_NARGS() > 2) && (!PG_ARGISNULL(2)))
77  preserve_collapsed = PG_GETARG_BOOL(2);
78 
79  /* Can't simplify points! */
80  if ( type == POINTTYPE || type == MULTIPOINTTYPE )
81  PG_RETURN_POINTER(geom);
82 
83  in = lwgeom_from_gserialized(geom);
84 
85  out = lwgeom_simplify(in, dist, preserve_collapsed);
86  if ( ! out ) PG_RETURN_NULL();
87 
88  /* COMPUTE_BBOX TAINTING */
89  if (in->bbox)
90  {
91  lwgeom_drop_bbox(out);
92  lwgeom_add_bbox(out);
93  }
94 
95  result = geometry_serialize(out);
96  lwgeom_free(out);
97  PG_FREE_IF_COPY(geom, 0);
98  PG_RETURN_POINTER(result);
99 }
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
GBOX * bbox
Definition: liblwgeom.h:398
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:635
LWGEOM * geom
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
Definition: lwgeom.c:1602
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:648
type
Definition: ovdump.py:41
Here is the call graph for this function: