PostGIS  2.3.7dev-r@@SVN_REVISION@@
Datum isvalid ( PG_FUNCTION_ARGS  )

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

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

1467 {
1468  GSERIALIZED *geom1;
1469  LWGEOM *lwgeom;
1470  bool result;
1471  GEOSGeom g1;
1472 
1473  geom1 = PG_GETARG_GSERIALIZED_P(0);
1474 
1475  /* Empty.IsValid() == TRUE */
1476  if ( gserialized_is_empty(geom1) )
1477  PG_RETURN_BOOL(true);
1478 
1479  initGEOS(lwpgnotice, lwgeom_geos_error);
1480 
1481  lwgeom = lwgeom_from_gserialized(geom1);
1482  if ( ! lwgeom )
1483  {
1484  lwpgerror("unable to deserialize input");
1485  }
1486  g1 = LWGEOM2GEOS(lwgeom, 0);
1487  lwgeom_free(lwgeom);
1488 
1489  if ( ! g1 )
1490  {
1491  /* should we drop the following
1492  * notice now that we have ST_isValidReason ?
1493  */
1494  lwpgnotice("%s", lwgeom_geos_errmsg);
1495  PG_RETURN_BOOL(FALSE);
1496  }
1497 
1498  result = GEOSisValid(g1);
1499  GEOSGeom_destroy(g1);
1500 
1501  if (result == 2)
1502  {
1503  elog(ERROR,"GEOS isvalid() threw an error!");
1504  PG_RETURN_NULL(); /*never get here */
1505  }
1506 
1507  PG_FREE_IF_COPY(geom1, 0);
1508  PG_RETURN_BOOL(result);
1509 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: g_serialized.c:153
void lwgeom_geos_error(const char *fmt,...)
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
#define FALSE
Definition: dbfopen.c:168

Here is the call graph for this function: