PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ isvalid()

Datum isvalid ( PG_FUNCTION_ARGS  )

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

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