PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ relate_full()

Datum relate_full ( PG_FUNCTION_ARGS  )

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

2483 {
2484  GSERIALIZED *geom1;
2485  GSERIALIZED *geom2;
2486  GEOSGeometry *g1, *g2;
2487  char *relate_str;
2488  text *result;
2489  int bnr = GEOSRELATE_BNR_OGC;
2490 
2491  /* TODO handle empty */
2492  geom1 = PG_GETARG_GSERIALIZED_P(0);
2493  geom2 = PG_GETARG_GSERIALIZED_P(1);
2494  gserialized_error_if_srid_mismatch(geom1, geom2, __func__);
2495 
2496  if ( PG_NARGS() > 2 )
2497  bnr = PG_GETARG_INT32(2);
2498 
2499  initGEOS(lwpgnotice, lwgeom_geos_error);
2500 
2501  g1 = POSTGIS2GEOS(geom1 );
2502  if (!g1)
2503  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
2504  g2 = POSTGIS2GEOS(geom2 );
2505  if (!g2)
2506  {
2507  GEOSGeom_destroy(g1);
2508  HANDLE_GEOS_ERROR("Second argument geometry could not be converted to GEOS");
2509  }
2510 
2511  POSTGIS_DEBUG(3, "constructed geometries ");
2512 
2513  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g1));
2514  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g2));
2515 
2516  relate_str = GEOSRelateBoundaryNodeRule(g1, g2, bnr);
2517 
2518  GEOSGeom_destroy(g1);
2519  GEOSGeom_destroy(g2);
2520 
2521  if (!relate_str) HANDLE_GEOS_ERROR("GEOSRelate");
2522 
2523  result = cstring_to_text(relate_str);
2524  GEOSFree(relate_str);
2525 
2526  PG_FREE_IF_COPY(geom1, 0);
2527  PG_FREE_IF_COPY(geom2, 1);
2528 
2529  PG_RETURN_TEXT_P(result);
2530 }
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
Definition: gserialized.c:404
void lwgeom_geos_error(const char *fmt,...)
#define HANDLE_GEOS_ERROR(label)
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)

References gserialized_error_if_srid_mismatch(), HANDLE_GEOS_ERROR, lwgeom_geos_error(), and POSTGIS2GEOS().

Here is the call graph for this function: