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

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

References COLLECTIONTYPE, geometry_serialize(), LINETYPE, lwerror(), lwgeom_from_gserialized(), lwgeom_make_valid(), lwtype_name(), MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, POINTTYPE, POLYGONTYPE, and LWGEOM::type.

56 {
57 #if POSTGIS_GEOS_VERSION < 33
58  elog(ERROR, "You need GEOS-3.3.0 or up for ST_MakeValid");
59  PG_RETURN_NULL();
60 #else /* POSTGIS_GEOS_VERSION >= 33 */
61 
62  GSERIALIZED *in, *out;
63  LWGEOM *lwgeom_in, *lwgeom_out;
64 
65  in = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
66  lwgeom_in = lwgeom_from_gserialized(in);
67 
68  switch ( lwgeom_in->type )
69  {
70  case POINTTYPE:
71  case MULTIPOINTTYPE:
72  case LINETYPE:
73  case POLYGONTYPE:
74  case MULTILINETYPE:
75  case MULTIPOLYGONTYPE:
76  case COLLECTIONTYPE:
77  break;
78 
79  default:
80  lwerror("ST_MakeValid: unsupported geometry type %s",
81  lwtype_name(lwgeom_in->type));
82  PG_RETURN_NULL();
83  break;
84  }
85 
86  lwgeom_out = lwgeom_make_valid(lwgeom_in);
87  if ( ! lwgeom_out )
88  {
89  PG_FREE_IF_COPY(in, 0);
90  PG_RETURN_NULL();
91  }
92 
93  out = geometry_serialize(lwgeom_out);
94 
95  PG_RETURN_POINTER(out);
96 #endif /* POSTGIS_GEOS_VERSION >= 33 */
97 }
#define LINETYPE
Definition: liblwgeom.h:61
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
uint8_t type
Definition: liblwgeom.h:352
#define MULTILINETYPE
Definition: liblwgeom.h:64
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function: