PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ isvalid()

Datum isvalid ( PG_FUNCTION_ARGS  )

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

1583 {
1584  GSERIALIZED *geom1;
1585  LWGEOM *lwgeom;
1586  char result;
1587  GEOSGeom g1;
1588 
1589  geom1 = PG_GETARG_GSERIALIZED_P(0);
1590 
1591  /* Empty.IsValid() == TRUE */
1592  if ( gserialized_is_empty(geom1) )
1593  PG_RETURN_BOOL(true);
1594 
1595  initGEOS(lwpgnotice, lwgeom_geos_error);
1596 
1597  lwgeom = lwgeom_from_gserialized(geom1);
1598  if ( ! lwgeom )
1599  {
1600  lwpgerror("unable to deserialize input");
1601  }
1602  g1 = LWGEOM2GEOS(lwgeom, 0);
1603  lwgeom_free(lwgeom);
1604 
1605  if ( ! g1 )
1606  {
1607  PG_RETURN_BOOL(false);
1608  }
1609 
1610  result = GEOSisValid(g1);
1611  GEOSGeom_destroy(g1);
1612 
1613  if (result == 2)
1614  {
1615  elog(ERROR,"GEOS isvalid() threw an error!");
1616  PG_RETURN_NULL(); /*never get here */
1617  }
1618 
1619  PG_FREE_IF_COPY(geom1, 0);
1620  PG_RETURN_BOOL(result);
1621 }
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:268
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: gserialized.c:181
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
void lwgeom_geos_error(const char *fmt,...)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1218

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

Here is the call graph for this function: