PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ ST_CleanGeometry()

Datum ST_CleanGeometry ( PG_FUNCTION_ARGS  )

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

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

Referenced by lwgeom_clean().

147 {
148 #if POSTGIS_GEOS_VERSION < 33
149  elog(ERROR, "You need GEOS-3.3.0 or up for ST_CleanGeometry");
150  PG_RETURN_NULL();
151 #else /* POSTGIS_GEOS_VERSION >= 33 */
152 
153  GSERIALIZED *in, *out;
154  LWGEOM *lwgeom_in, *lwgeom_out;
155 
156  in = PG_GETARG_GSERIALIZED_P(0);
157  lwgeom_in = lwgeom_from_gserialized(in);
158 
159  /* Short-circuit: empty geometry are the cleanest ! */
160 #if 0
161  if ( lwgeom_is_empty(lwgeom_in) )
162  {
163  out = geometry_serialize(lwgeom_in);
164  PG_FREE_IF_COPY(in, 0);
165  PG_RETURN_POINTER(out);
166  }
167 #endif
168 
169  lwgeom_out = lwgeom_clean(lwgeom_in);
170  if ( ! lwgeom_out )
171  {
172  PG_FREE_IF_COPY(in, 0);
173  PG_RETURN_NULL();
174  }
175 
176  out = geometry_serialize(lwgeom_out);
177  PG_RETURN_POINTER(out);
178 
179 #endif /* POSTGIS_GEOS_VERSION >= 33 */
180 }
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:1297
Here is the call graph for this function:
Here is the caller graph for this function: