PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ isvalid()

Datum isvalid ( PG_FUNCTION_ARGS  )

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

1528 {
1529  GSERIALIZED *geom1;
1530  LWGEOM *lwgeom;
1531  char result;
1532  GEOSGeom g1;
1533 
1534  geom1 = PG_GETARG_GSERIALIZED_P(0);
1535 
1536  /* Empty.IsValid() == TRUE */
1537  if ( gserialized_is_empty(geom1) )
1538  PG_RETURN_BOOL(true);
1539 
1540  initGEOS(lwpgnotice, lwgeom_geos_error);
1541 
1542  lwgeom = lwgeom_from_gserialized(geom1);
1543  if ( ! lwgeom )
1544  {
1545  lwpgerror("unable to deserialize input");
1546  }
1547  g1 = LWGEOM2GEOS(lwgeom, 0);
1548  lwgeom_free(lwgeom);
1549 
1550  if ( ! g1 )
1551  {
1552  PG_RETURN_BOOL(false);
1553  }
1554 
1555  result = GEOSisValid(g1);
1556  GEOSGeom_destroy(g1);
1557 
1558  if (result == 2)
1559  {
1560  elog(ERROR,"GEOS isvalid() threw an error!");
1561  PG_RETURN_NULL(); /*never get here */
1562  }
1563 
1564  PG_FREE_IF_COPY(geom1, 0);
1565  PG_RETURN_BOOL(result);
1566 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: gserialized.c:152
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
void lwgeom_geos_error(const char *fmt,...)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155

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

Here is the call graph for this function: