1656{
1658 const GEOSGeometry *g1 = NULL;
1659 char *values[3];
1660 char *geos_reason = NULL;
1661 char *reason = NULL;
1662 GEOSGeometry *geos_location = NULL;
1664 char valid = 0;
1666 TupleDesc tupdesc;
1667 HeapTuple tuple;
1668 AttInMetadata *attinmeta;
1669 int flags = 0;
1670
1671
1672
1673
1674
1675 get_call_result_type(fcinfo, 0, &tupdesc);
1676 BlessTupleDesc(tupdesc);
1677
1678
1679
1680
1681
1682 attinmeta = TupleDescGetAttInMetadata(tupdesc);
1683
1684 geom = PG_GETARG_GSERIALIZED_P(0);
1685 flags = PG_GETARG_INT32(1);
1686
1688
1690
1691 if ( g1 )
1692 {
1693 valid = GEOSisValidDetail(g1, flags, &geos_reason, &geos_location);
1694 GEOSGeom_destroy((GEOSGeometry *)g1);
1695 if ( geos_reason )
1696 {
1697 reason = pstrdup(geos_reason);
1698 GEOSFree(geos_reason);
1699 }
1700 if ( geos_location )
1701 {
1702 location =
GEOS2LWGEOM(geos_location, GEOSHasZ(geos_location));
1703 GEOSGeom_destroy(geos_location);
1704 }
1705
1706 if (valid == 2)
1707 {
1708
1709 lwpgerror("GEOS isvaliddetail() threw an exception!");
1710 PG_RETURN_NULL();
1711 }
1712 }
1713 else
1714 {
1715
1717 }
1718
1719
1720 values[0] = valid ? "t" : "f";
1721
1722
1723 values[1] = reason;
1724
1725
1727
1728 tuple = BuildTupleFromCStrings(attinmeta, values);
1729 result = (HeapTupleHeader) palloc(tuple->t_len);
1730 memcpy(
result, tuple->t_data, tuple->t_len);
1731 heap_freetuple(tuple);
1732
1733 PG_RETURN_HEAPTUPLEHEADER(
result);
1734}
char result[OUT_DOUBLE_BUFFER_SIZE]
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
void lwgeom_geos_error(const char *fmt,...)
void(*) LWGEOM GEOS2LWGEOM)(const GEOSGeometry *geom, uint8_t want3d)
char * lwgeom_to_hexwkb_buffer(const LWGEOM *geom, uint8_t variant)
GEOSGeometry * POSTGIS2GEOS(const GSERIALIZED *pglwgeom)