PostGIS  2.5.0dev-r@@SVN_REVISION@@
void errorIfGeometryCollection ( GSERIALIZED g1,
GSERIALIZED g2 
)

Throws an ereport ERROR if either geometry is a COLLECTIONTYPE.

Additionally displays a HINT of the first 80 characters of the WKT representation of the problematic geometry so a user knows which parameter and which geometry is causing the problem.

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

References COLLECTIONTYPE, gserialized_get_type(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_to_wkt(), lwmessage_truncate(), and WKT_SFSQL.

Referenced by contains(), containsproperly(), coveredby(), covers(), crosses(), disjoint(), geos_intersects(), overlaps(), relate_full(), relate_pattern(), ST_Equals(), and touches().

1450 {
1451  int t1 = gserialized_get_type(g1);
1452  int t2 = gserialized_get_type(g2);
1453 
1454  char *hintmsg;
1455  char *hintwkt;
1456  size_t hintsz;
1457  LWGEOM *lwgeom;
1458 
1459  if ( t1 == COLLECTIONTYPE)
1460  {
1461  lwgeom = lwgeom_from_gserialized(g1);
1462  hintwkt = lwgeom_to_wkt(lwgeom, WKT_SFSQL, DBL_DIG, &hintsz);
1463  lwgeom_free(lwgeom);
1464  hintmsg = lwmessage_truncate(hintwkt, 0, hintsz-1, 80, 1);
1465  ereport(ERROR,
1466  (errmsg("Relate Operation called with a LWGEOMCOLLECTION type. This is unsupported."),
1467  errhint("Change argument 1: '%s'", hintmsg))
1468  );
1469  pfree(hintwkt);
1470  pfree(hintmsg);
1471  }
1472  else if (t2 == COLLECTIONTYPE)
1473  {
1474  lwgeom = lwgeom_from_gserialized(g2);
1475  hintwkt = lwgeom_to_wkt(lwgeom, WKT_SFSQL, DBL_DIG, &hintsz);
1476  hintmsg = lwmessage_truncate(hintwkt, 0, hintsz-1, 80, 1);
1477  lwgeom_free(lwgeom);
1478  ereport(ERROR,
1479  (errmsg("Relate Operation called with a LWGEOMCOLLECTION type. This is unsupported."),
1480  errhint("Change argument 2: '%s'", hintmsg))
1481  );
1482  pfree(hintwkt);
1483  pfree(hintmsg);
1484  }
1485 }
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:86
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:675
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
char * lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection)
Definition: lwutil.c:261
#define WKT_SFSQL
Definition: liblwgeom.h:2069
#define COLLECTIONTYPE
Definition: liblwgeom.h:90

Here is the call graph for this function:

Here is the caller graph for this function: