PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ST_MakeValid()

Datum ST_MakeValid ( PG_FUNCTION_ARGS  )

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

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 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POLYGONTYPE
Definition: liblwgeom.h:87
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.
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
uint8_t type
Definition: liblwgeom.h:399

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

Here is the call graph for this function: