1533{
1535 const GEOSGeometry *g1 = NULL;
1536 char *values[3];
1537 char *geos_reason = NULL;
1538 char *reason = NULL;
1539 GEOSGeometry *geos_location = NULL;
1541 char valid = 0;
1542 HeapTupleHeader result;
1543 TupleDesc tupdesc;
1544 HeapTuple tuple;
1545 AttInMetadata *attinmeta;
1546 int flags = 0;
1547
1548
1549
1550
1551
1552 get_call_result_type(fcinfo, 0, &tupdesc);
1553 BlessTupleDesc(tupdesc);
1554
1555
1556
1557
1558
1559 attinmeta = TupleDescGetAttInMetadata(tupdesc);
1560
1561 geom = PG_GETARG_GSERIALIZED_P(0);
1562 flags = PG_GETARG_INT32(1);
1563
1565
1567
1568 if ( g1 )
1569 {
1570 valid = GEOSisValidDetail(g1, flags, &geos_reason, &geos_location);
1571 GEOSGeom_destroy((GEOSGeometry *)g1);
1572 if ( geos_reason )
1573 {
1574 reason = pstrdup(geos_reason);
1575 GEOSFree(geos_reason);
1576 }
1577 if ( geos_location )
1578 {
1579 location =
GEOS2LWGEOM(geos_location, GEOSHasZ(geos_location));
1580 GEOSGeom_destroy(geos_location);
1581 }
1582
1583 if (valid == 2)
1584 {
1585
1586 lwpgerror("GEOS isvaliddetail() threw an exception!");
1587 PG_RETURN_NULL();
1588 }
1589 }
1590 else
1591 {
1592
1594 }
1595
1596
1597 values[0] = valid ? "t" : "f";
1598
1599
1600 values[1] = reason;
1601
1602
1604
1605 tuple = BuildTupleFromCStrings(attinmeta, values);
1606 result = (HeapTupleHeader) palloc(tuple->t_len);
1607 memcpy(result, tuple->t_data, tuple->t_len);
1608 heap_freetuple(tuple);
1609
1610 PG_RETURN_HEAPTUPLEHEADER(result);
1611}
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, uint8_t want3d)
void lwgeom_geos_error(const char *fmt,...)
char * lwgeom_to_hexwkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)