PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ errorIfGeometryCollection()

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 1357 of file postgis/lwgeom_geos.c.

1358 {
1359  int t1 = gserialized_get_type(g1);
1360  int t2 = gserialized_get_type(g2);
1361 
1362  char *hintmsg;
1363  char *hintwkt;
1364  size_t hintsz;
1365  LWGEOM *lwgeom;
1366 
1367  if ( t1 == COLLECTIONTYPE)
1368  {
1369  lwgeom = lwgeom_from_gserialized(g1);
1370  hintwkt = lwgeom_to_wkt(lwgeom, WKT_SFSQL, DBL_DIG, &hintsz);
1371  lwgeom_free(lwgeom);
1372  hintmsg = lwmessage_truncate(hintwkt, 0, hintsz-1, 80, 1);
1373  ereport(ERROR,
1374  (errmsg("Relate Operation called with a LWGEOMCOLLECTION type. This is unsupported."),
1375  errhint("Change argument 1: '%s'", hintmsg))
1376  );
1377  pfree(hintwkt);
1378  pfree(hintmsg);
1379  }
1380  else if (t2 == COLLECTIONTYPE)
1381  {
1382  lwgeom = lwgeom_from_gserialized(g2);
1383  hintwkt = lwgeom_to_wkt(lwgeom, WKT_SFSQL, DBL_DIG, &hintsz);
1384  hintmsg = lwmessage_truncate(hintwkt, 0, hintsz-1, 80, 1);
1385  lwgeom_free(lwgeom);
1386  ereport(ERROR,
1387  (errmsg("Relate Operation called with a LWGEOMCOLLECTION type. This is unsupported."),
1388  errhint("Change argument 2: '%s'", hintmsg))
1389  );
1390  pfree(hintwkt);
1391  pfree(hintmsg);
1392  }
1393 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
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
#define WKT_SFSQL
Definition: liblwgeom.h:2076
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
char * lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection)
Definition: lwutil.c:261
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:676

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(), overlaps(), relate_full(), relate_pattern(), ST_Equals(), and touches().

Here is the call graph for this function:
Here is the caller graph for this function: