PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ relate_full()

Datum relate_full ( PG_FUNCTION_ARGS  )

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

References error_if_srid_mismatch(), errorIfGeometryCollection(), gserialized_get_srid(), HANDLE_GEOS_ERROR, lwgeom_geos_error(), PG_FUNCTION_INFO_V1(), POSTGIS2GEOS(), and ST_Equals().

Referenced by relate_pattern().

2444 {
2445  GSERIALIZED *geom1;
2446  GSERIALIZED *geom2;
2447  GEOSGeometry *g1, *g2;
2448  char *relate_str;
2449  text *result;
2450  int bnr = GEOSRELATE_BNR_OGC;
2451 
2452  POSTGIS_DEBUG(2, "in relate_full()");
2453 
2454  /* TODO handle empty */
2455 
2456  geom1 = PG_GETARG_GSERIALIZED_P(0);
2457  geom2 = PG_GETARG_GSERIALIZED_P(1);
2458 
2459  if ( PG_NARGS() > 2 )
2460  {
2461  bnr = PG_GETARG_INT32(2);
2462  }
2463 
2464  errorIfGeometryCollection(geom1,geom2);
2466 
2467  initGEOS(lwpgnotice, lwgeom_geos_error);
2468 
2469  g1 = POSTGIS2GEOS(geom1 );
2470  if (!g1)
2471  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
2472  g2 = POSTGIS2GEOS(geom2 );
2473  if (!g2)
2474  {
2475  GEOSGeom_destroy(g1);
2476  HANDLE_GEOS_ERROR("Second argument geometry could not be converted to GEOS");
2477  }
2478 
2479  POSTGIS_DEBUG(3, "constructed geometries ");
2480 
2481  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g1));
2482  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g2));
2483 
2484  relate_str = GEOSRelateBoundaryNodeRule(g1, g2, bnr);
2485 
2486  GEOSGeom_destroy(g1);
2487  GEOSGeom_destroy(g2);
2488 
2489  if (!relate_str) HANDLE_GEOS_ERROR("GEOSRelate");
2490 
2491  result = cstring_to_text(relate_str);
2492  GEOSFree(relate_str);
2493 
2494  PG_FREE_IF_COPY(geom1, 0);
2495  PG_FREE_IF_COPY(geom2, 1);
2496 
2497  PG_RETURN_TEXT_P(result);
2498 }
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:336
void lwgeom_geos_error(const char *fmt,...)
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)
#define HANDLE_GEOS_ERROR(label)
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:99
void errorIfGeometryCollection(GSERIALIZED *g1, GSERIALIZED *g2)
Throws an ereport ERROR if either geometry is a COLLECTIONTYPE.
Here is the call graph for this function:
Here is the caller graph for this function: