PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ relate_full()

Datum relate_full ( PG_FUNCTION_ARGS  )

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

2443 {
2444  GSERIALIZED *geom1;
2445  GSERIALIZED *geom2;
2446  GEOSGeometry *g1, *g2;
2447  char *relate_str;
2448  text *result;
2449  int bnr = GEOSRELATE_BNR_OGC;
2450 
2451  POSTGIS_DEBUG(2, "in relate_full()");
2452 
2453  /* TODO handle empty */
2454 
2455  geom1 = PG_GETARG_GSERIALIZED_P(0);
2456  geom2 = PG_GETARG_GSERIALIZED_P(1);
2457 
2458  if ( PG_NARGS() > 2 )
2459  {
2460  bnr = PG_GETARG_INT32(2);
2461  }
2462 
2463  errorIfGeometryCollection(geom1,geom2);
2465 
2466  initGEOS(lwpgnotice, lwgeom_geos_error);
2467 
2468  g1 = POSTGIS2GEOS(geom1 );
2469  if (!g1)
2470  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
2471  g2 = POSTGIS2GEOS(geom2 );
2472  if (!g2)
2473  {
2474  GEOSGeom_destroy(g1);
2475  HANDLE_GEOS_ERROR("Second argument geometry could not be converted to GEOS");
2476  }
2477 
2478  POSTGIS_DEBUG(3, "constructed geometries ");
2479 
2480  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g1));
2481  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g2));
2482 
2483  relate_str = GEOSRelateBoundaryNodeRule(g1, g2, bnr);
2484 
2485  GEOSGeom_destroy(g1);
2486  GEOSGeom_destroy(g2);
2487 
2488  if (!relate_str) HANDLE_GEOS_ERROR("GEOSRelate");
2489 
2490  result = cstring_to_text(relate_str);
2491  GEOSFree(relate_str);
2492 
2493  PG_FREE_IF_COPY(geom1, 0);
2494  PG_FREE_IF_COPY(geom2, 1);
2495 
2496  PG_RETURN_TEXT_P(result);
2497 }
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:100
void lwgeom_geos_error(const char *fmt,...)
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:338
#define HANDLE_GEOS_ERROR(label)
void errorIfGeometryCollection(GSERIALIZED *g1, GSERIALIZED *g2)
Throws an ereport ERROR if either geometry is a COLLECTIONTYPE.
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)

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

Here is the call graph for this function: