PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ LWGEOM_simplify2d()

Datum LWGEOM_simplify2d ( PG_FUNCTION_ARGS  )

Definition at line 65 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_SetEffectiveArea(), lwgeom_simplify(), MULTIPOINTTYPE, PG_FUNCTION_INFO_V1(), POINTTYPE, and ovdump::type.

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 = true;
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 ) lwgeom_add_bbox(out);
89 
90  result = geometry_serialize(out);
91  lwgeom_free(out);
92  PG_FREE_IF_COPY(geom, 0);
93  PG_RETURN_POINTER(result);
94 }
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:400
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
LWGEOM * geom
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
Definition: lwgeom.c:1842
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:686
type
Definition: ovdump.py:41
Here is the call graph for this function: