910 GEOSGeometry* geosout;
913 LWDEBUG(1,
"lwgeom_make_valid enter");
925 if (!lwgeom_out)
lwerror(
"Could not make a geos friendly geometry out of input");
927 LWDEBUGF(4,
"Input geom %p made GEOS-valid as %p", lwgeom_in, lwgeom_out);
930 if ( lwgeom_in != lwgeom_out ) {
940 LWDEBUG(4,
"geom converted to GEOS");
943 #if POSTGIS_GEOS_VERSION < 30800
944 geosout = LWGEOM_GEOS_makeValid(geosgeom);
945 #elif POSTGIS_GEOS_VERSION < 31000
946 geosout = GEOSMakeValid(geosgeom);
948 if (!make_valid_params) {
949 geosout = GEOSMakeValid(geosgeom);
962 memset(param_list, 0,
sizeof(param_list));
964 GEOSMakeValidParams *params = GEOSMakeValidParams_create();
967 if (strcasecmp(
value,
"linework") == 0) {
968 GEOSMakeValidParams_setMethod(params, GEOS_MAKE_VALID_LINEWORK);
970 else if (strcasecmp(
value,
"structure") == 0) {
971 GEOSMakeValidParams_setMethod(params, GEOS_MAKE_VALID_STRUCTURE);
975 GEOSMakeValidParams_destroy(params);
976 lwerror(
"Unsupported value for 'method', '%s'. Use 'linework' or 'structure'.",
value);
981 if (strcasecmp(
value,
"true") == 0) {
982 GEOSMakeValidParams_setKeepCollapsed(params, 1);
984 else if (strcasecmp(
value,
"false") == 0) {
985 GEOSMakeValidParams_setKeepCollapsed(params, 0);
989 GEOSMakeValidParams_destroy(params);
990 lwerror(
"Unsupported value for 'keepcollapsed', '%s'. Use 'true' or 'false'",
value);
993 geosout = GEOSMakeValidWithParams(geosgeom, params);
994 GEOSMakeValidParams_destroy(params);
997 GEOSGeom_destroy(geosgeom);
998 if (!geosout)
return NULL;
1001 GEOSGeom_destroy(geosout);
1007 LWDEBUG(3,
"lwgeom_make_valid: forcing multi");
1010 assert(lwgeom_in != lwgeom_out);
1011 ogeoms[0] = lwgeom_out;
1014 lwgeom_out->
bbox = NULL;
1018 lwgeom_out->
srid = lwgeom_in->srid;
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, uint8_t want3d)
void lwgeom_geos_error(const char *fmt,...)
static LWGEOM * lwgeom_make_geos_friendly(LWGEOM *geom)
void lwgeom_free(LWGEOM *geom)
#define FLAGS_GET_Z(flags)
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
void * lwalloc(size_t size)
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
uint8_t MULTITYPE[NUMTYPES]
Look-up for the correct MULTI* type promotion for singleton types.
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
const char * option_list_search(char **olist, const char *key)
Returns null if the key cannot be found.
void option_list_parse(char *input, char **olist)
option_list is a null-terminated list of strings, where every odd string is a key and every even stri...