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

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

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

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

Here is the call graph for this function: