PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ isvalid()

Datum isvalid ( PG_FUNCTION_ARGS  )

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

1529 {
1530  GSERIALIZED *geom1;
1531  LWGEOM *lwgeom;
1532  char result;
1533  GEOSGeom g1;
1534 
1535  geom1 = PG_GETARG_GSERIALIZED_P(0);
1536 
1537  /* Empty.IsValid() == TRUE */
1538  if ( gserialized_is_empty(geom1) )
1539  PG_RETURN_BOOL(true);
1540 
1541  initGEOS(lwpgnotice, lwgeom_geos_error);
1542 
1543  lwgeom = lwgeom_from_gserialized(geom1);
1544  if ( ! lwgeom )
1545  {
1546  lwpgerror("unable to deserialize input");
1547  }
1548  g1 = LWGEOM2GEOS(lwgeom, 0);
1549  lwgeom_free(lwgeom);
1550 
1551  if ( ! g1 )
1552  {
1553  PG_RETURN_BOOL(false);
1554  }
1555 
1556  result = GEOSisValid(g1);
1557  GEOSGeom_destroy(g1);
1558 
1559  if (result == 2)
1560  {
1561  elog(ERROR,"GEOS isvalid() threw an error!");
1562  PG_RETURN_NULL(); /*never get here */
1563  }
1564 
1565  PG_FREE_IF_COPY(geom1, 0);
1566  PG_RETURN_BOOL(result);
1567 }
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: