PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ isvalid()

Datum isvalid ( PG_FUNCTION_ARGS  )

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

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