PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum ST_CleanGeometry ( PG_FUNCTION_ARGS  )

Definition at line 148 of file postgis/lwgeom_geos_clean.c.

References geometry_serialize(), lwgeom_clean(), lwgeom_from_gserialized(), and lwgeom_is_empty().

149 {
150 #if POSTGIS_GEOS_VERSION < 33
151  elog(ERROR, "You need GEOS-3.3.0 or up for ST_CleanGeometry");
152  PG_RETURN_NULL();
153 #else /* POSTGIS_GEOS_VERSION >= 33 */
154 
155  GSERIALIZED *in, *out;
156  LWGEOM *lwgeom_in, *lwgeom_out;
157 
158  in = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
159  lwgeom_in = lwgeom_from_gserialized(in);
160 
161  /* Short-circuit: empty geometry are the cleanest ! */
162 #if 0
163  if ( lwgeom_is_empty(lwgeom_in) )
164  {
165  out = geometry_serialize(lwgeom_in);
166  PG_FREE_IF_COPY(in, 0);
167  PG_RETURN_POINTER(out);
168  }
169 #endif
170 
171  lwgeom_out = lwgeom_clean(lwgeom_in);
172  if ( ! lwgeom_out )
173  {
174  PG_FREE_IF_COPY(in, 0);
175  PG_RETURN_NULL();
176  }
177 
178  out = geometry_serialize(lwgeom_out);
179  PG_RETURN_POINTER(out);
180 
181 #endif /* POSTGIS_GEOS_VERSION >= 33 */
182 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
static LWGEOM * lwgeom_clean(LWGEOM *lwgeom_in)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1229

Here is the call graph for this function: