PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ isvalid()

Datum isvalid ( PG_FUNCTION_ARGS  )

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

1457{
1458 GSERIALIZED *geom1;
1459 LWGEOM *lwgeom;
1460 char result;
1461 GEOSGeom g1;
1462
1463 geom1 = PG_GETARG_GSERIALIZED_P(0);
1464
1465 /* Empty.IsValid() == TRUE */
1466 if ( gserialized_is_empty(geom1) )
1467 PG_RETURN_BOOL(true);
1468
1469 initGEOS(lwpgnotice, lwgeom_geos_error);
1470
1471 lwgeom = lwgeom_from_gserialized(geom1);
1472 if ( ! lwgeom )
1473 {
1474 lwpgerror("unable to deserialize input");
1475 }
1476 g1 = LWGEOM2GEOS(lwgeom, 0);
1477 lwgeom_free(lwgeom);
1478
1479 if ( ! g1 )
1480 {
1481 /* should we drop the following
1482 * notice now that we have ST_isValidReason ?
1483 */
1484 lwpgnotice("%s", lwgeom_geos_errmsg);
1485 PG_RETURN_BOOL(false);
1486 }
1487
1488 result = GEOSisValid(g1);
1489 GEOSGeom_destroy(g1);
1490
1491 if (result == 2)
1492 {
1493 elog(ERROR,"GEOS isvalid() threw an error!");
1494 PG_RETURN_NULL(); /*never get here */
1495 }
1496
1497 PG_FREE_IF_COPY(geom1, 0);
1498 PG_RETURN_BOOL(result);
1499}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
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, and lwgeom_geos_error().

Here is the call graph for this function: