PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ isvalid()

Datum isvalid ( PG_FUNCTION_ARGS  )

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

1555 {
1556  GSERIALIZED *geom1;
1557  LWGEOM *lwgeom;
1558  char result;
1559  GEOSGeom g1;
1560 
1561  geom1 = PG_GETARG_GSERIALIZED_P(0);
1562 
1563  /* Empty.IsValid() == TRUE */
1564  if ( gserialized_is_empty(geom1) )
1565  PG_RETURN_BOOL(true);
1566 
1567  initGEOS(lwpgnotice, lwgeom_geos_error);
1568 
1569  lwgeom = lwgeom_from_gserialized(geom1);
1570  if ( ! lwgeom )
1571  {
1572  lwpgerror("unable to deserialize input");
1573  }
1574  g1 = LWGEOM2GEOS(lwgeom, 0);
1575  lwgeom_free(lwgeom);
1576 
1577  if ( ! g1 )
1578  {
1579  PG_RETURN_BOOL(false);
1580  }
1581 
1582  result = GEOSisValid(g1);
1583  GEOSGeom_destroy(g1);
1584 
1585  if (result == 2)
1586  {
1587  elog(ERROR,"GEOS isvalid() threw an error!");
1588  PG_RETURN_NULL(); /*never get here */
1589  }
1590 
1591  PG_FREE_IF_COPY(geom1, 0);
1592  PG_RETURN_BOOL(result);
1593 }
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:1138

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

Here is the call graph for this function: