PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ST_MakeValid()

Datum ST_MakeValid ( PG_FUNCTION_ARGS  )

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

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

43 {
44  GSERIALIZED *in, *out;
45  LWGEOM *lwgeom_in, *lwgeom_out;
46 
47  in = PG_GETARG_GSERIALIZED_P(0);
48  lwgeom_in = lwgeom_from_gserialized(in);
49 
50  switch ( lwgeom_in->type )
51  {
52  case POINTTYPE:
53  case MULTIPOINTTYPE:
54  case LINETYPE:
55  case POLYGONTYPE:
56  case MULTILINETYPE:
57  case MULTIPOLYGONTYPE:
58  case COLLECTIONTYPE:
59  break;
60 
61  default:
62  lwpgerror("ST_MakeValid: unsupported geometry type %s",
63  lwtype_name(lwgeom_in->type));
64  PG_RETURN_NULL();
65  break;
66  }
67 
68  lwgeom_out = lwgeom_make_valid(lwgeom_in);
69  if ( ! lwgeom_out )
70  {
71  PG_FREE_IF_COPY(in, 0);
72  PG_RETURN_NULL();
73  }
74 
75  out = geometry_serialize(lwgeom_out);
76 
77  PG_RETURN_POINTER(out);
78 }
#define LINETYPE
Definition: liblwgeom.h:86
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function: