29 #include "utils/builtins.h"
32 #include "../postgis_config.h"
37 #include "lwgeom_pg.h"
47 LWGEOM *lwgeom_in, *lwgeom_out;
49 in = PG_GETARG_GSERIALIZED_P_COPY(0);
52 switch ( lwgeom_in->
type )
64 lwpgerror(
"ST_MakeValid: unsupported geometry type %s",
70 if(PG_NARGS() > 1 && ! PG_ARGISNULL(1)) {
71 char *make_valid_params_str = text_to_cstring(PG_GETARG_TEXT_P(1));
80 PG_FREE_IF_COPY(in, 0);
84 out = geometry_serialize(lwgeom_out);
85 if ( lwgeom_out != lwgeom_in ) {
88 PG_FREE_IF_COPY(in, 0);
90 PG_RETURN_POINTER(out);
109 lwpgnotice(
"lwgeom_clean: dimensional collapse (%d to %d)",
119 lwpgnotice(
"lwgeom_clean: mixed-type output (%s) "
120 "from single-type input (%s)",
141 LWGEOM *lwgeom_in, *lwgeom_out;
143 in = PG_GETARG_GSERIALIZED_P(0);
150 out = geometry_serialize(lwgeom_in);
151 PG_FREE_IF_COPY(in, 0);
152 PG_RETURN_POINTER(out);
159 PG_FREE_IF_COPY(in, 0);
163 out = geometry_serialize(lwgeom_out);
164 PG_RETURN_POINTER(out);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWGEOM * lwgeom_make_valid_params(LWGEOM *geom, char *make_valid_params)
void lwgeom_free(LWGEOM *geom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
int lwgeom_dimensionality(const LWGEOM *geom)
Return the dimensionality (relating to point/line/poly) of an lwgeom.
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
This library is the generic geometry handling section of PostGIS.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
static LWGEOM * lwgeom_clean(LWGEOM *lwgeom_in)
Datum ST_CleanGeometry(PG_FUNCTION_ARGS)
Datum ST_MakeValid(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(ST_MakeValid)