Attempts to make an invalid geometries valid w/out losing points.
855{
856 int is3d;
857 GEOSGeom geosgeom;
858 GEOSGeometry* geosout;
860
862
863
864
865
866
867
869
870 lwgeom_out = lwgeom_in;
872 if (!geosgeom)
873 {
875 "Original geom can't be converted to GEOS (%s)"
876 " - will try cleaning that up first",
878
880 if (!lwgeom_out)
lwerror(
"Could not make a valid geometry out of input");
881
882
883
885 if (!geosgeom)
886 {
888 return NULL;
889 }
890 }
891 else
892 {
893 LWDEBUG(4,
"original geom converted to GEOS");
894 lwgeom_out = lwgeom_in;
895 }
896
897#if POSTGIS_GEOS_VERSION < 38
898 geosout = LWGEOM_GEOS_makeValid(geosgeom);
899#else
900 geosout = GEOSMakeValid(geosgeom);
901#endif
902 GEOSGeom_destroy(geosgeom);
903 if (!geosout) return NULL;
904
906 GEOSGeom_destroy(geosout);
907
909 {
912 LWDEBUG(3,
"lwgeom_make_valid: forcing multi");
913
914
915 assert(lwgeom_in != lwgeom_out);
916 ogeoms[0] = lwgeom_out;
919 lwgeom_out->
bbox = NULL;
920 lwgeom_out = ogeom;
921 }
922
923 lwgeom_out->
srid = lwgeom_in->srid;
924 return lwgeom_out;
925}
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)
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
#define FLAGS_GET_Z(flags)
void * lwalloc(size_t size)
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
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.