PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ isvalid()

Datum isvalid ( PG_FUNCTION_ARGS  )

Definition at line 1396 of file postgis/lwgeom_geos.c.

1397 {
1398  GSERIALIZED *geom1;
1399  LWGEOM *lwgeom;
1400  char result;
1401  GEOSGeom g1;
1402 
1403  geom1 = PG_GETARG_GSERIALIZED_P(0);
1404 
1405  /* Empty.IsValid() == TRUE */
1406  if ( gserialized_is_empty(geom1) )
1407  PG_RETURN_BOOL(true);
1408 
1409  initGEOS(lwpgnotice, lwgeom_geos_error);
1410 
1411  lwgeom = lwgeom_from_gserialized(geom1);
1412  if ( ! lwgeom )
1413  {
1414  lwpgerror("unable to deserialize input");
1415  }
1416  g1 = LWGEOM2GEOS(lwgeom, 0);
1417  lwgeom_free(lwgeom);
1418 
1419  if ( ! g1 )
1420  {
1421  /* should we drop the following
1422  * notice now that we have ST_isValidReason ?
1423  */
1424  lwpgnotice("%s", lwgeom_geos_errmsg);
1425  PG_RETURN_BOOL(false);
1426  }
1427 
1428  result = GEOSisValid(g1);
1429  GEOSGeom_destroy(g1);
1430 
1431  if (result == 2)
1432  {
1433  elog(ERROR,"GEOS isvalid() threw an error!");
1434  PG_RETURN_NULL(); /*never get here */
1435  }
1436 
1437  PG_FREE_IF_COPY(geom1, 0);
1438  PG_RETURN_BOOL(result);
1439 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: g_serialized.c:179
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
void lwgeom_geos_error(const char *fmt,...)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144

References gserialized_is_empty(), LWGEOM2GEOS(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_geos_errmsg, and lwgeom_geos_error().

Here is the call graph for this function: