PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ isvalid()

Datum isvalid ( PG_FUNCTION_ARGS  )

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

1645 {
1646  GSERIALIZED *geom1;
1647  LWGEOM *lwgeom;
1648  char result;
1649  GEOSGeom g1;
1650 
1651  geom1 = PG_GETARG_GSERIALIZED_P(0);
1652 
1653  /* Empty.IsValid() == TRUE */
1654  if ( gserialized_is_empty(geom1) )
1655  PG_RETURN_BOOL(true);
1656 
1657  initGEOS(lwpgnotice, lwgeom_geos_error);
1658 
1659  lwgeom = lwgeom_from_gserialized(geom1);
1660  if ( ! lwgeom )
1661  {
1662  lwpgerror("unable to deserialize input");
1663  }
1664  g1 = LWGEOM2GEOS(lwgeom, 0);
1665  lwgeom_free(lwgeom);
1666 
1667  if ( ! g1 )
1668  {
1669  PG_RETURN_BOOL(false);
1670  }
1671 
1672  result = GEOSisValid(g1);
1673  GEOSGeom_destroy(g1);
1674 
1675  if (result == 2)
1676  {
1677  elog(ERROR,"GEOS isvalid() threw an error!");
1678  PG_RETURN_NULL(); /*never get here */
1679  }
1680 
1681  PG_FREE_IF_COPY(geom1, 0);
1682  PG_RETURN_BOOL(result);
1683 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
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:1155

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

Here is the call graph for this function: