PostGIS  3.0.0dev-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 1354 of file postgis/lwgeom_geos.c.

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

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

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