PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ isvalid()

Datum isvalid ( PG_FUNCTION_ARGS  )

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

1621 {
1622  GSERIALIZED *geom1;
1623  LWGEOM *lwgeom;
1624  char result;
1625  GEOSGeom g1;
1626 
1627  geom1 = PG_GETARG_GSERIALIZED_P(0);
1628 
1629  /* Empty.IsValid() == TRUE */
1630  if ( gserialized_is_empty(geom1) )
1631  PG_RETURN_BOOL(true);
1632 
1633  initGEOS(lwpgnotice, lwgeom_geos_error);
1634 
1635  lwgeom = lwgeom_from_gserialized(geom1);
1636  if ( ! lwgeom )
1637  {
1638  lwpgerror("unable to deserialize input");
1639  }
1640  g1 = LWGEOM2GEOS(lwgeom, 0);
1641  lwgeom_free(lwgeom);
1642 
1643  if ( ! g1 )
1644  {
1645  /* should we drop the following
1646  * notice now that we have ST_isValidReason ?
1647  */
1648  lwpgnotice("%s", lwgeom_geos_errmsg);
1649  PG_RETURN_BOOL(false);
1650  }
1651 
1652  result = GEOSisValid(g1);
1653  GEOSGeom_destroy(g1);
1654 
1655  if (result == 2)
1656  {
1657  elog(ERROR,"GEOS isvalid() threw an error!");
1658  PG_RETURN_NULL(); /*never get here */
1659  }
1660 
1661  PG_FREE_IF_COPY(geom1, 0);
1662  PG_RETURN_BOOL(result);
1663 }
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
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
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_errmsg, lwgeom_geos_error(), and result.

Here is the call graph for this function: