PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum relate_full ( PG_FUNCTION_ARGS  )

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

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

2584 {
2585  GSERIALIZED *geom1;
2586  GSERIALIZED *geom2;
2587  GEOSGeometry *g1, *g2;
2588  char *relate_str;
2589  text *result;
2590  int bnr = GEOSRELATE_BNR_OGC;
2591 
2592  POSTGIS_DEBUG(2, "in relate_full()");
2593 
2594  /* TODO handle empty */
2595 
2596  geom1 = PG_GETARG_GSERIALIZED_P(0);
2597  geom2 = PG_GETARG_GSERIALIZED_P(1);
2598 
2599  if ( PG_NARGS() > 2 )
2600  {
2601  bnr = PG_GETARG_INT32(2);
2602  }
2603 
2604  errorIfGeometryCollection(geom1,geom2);
2606 
2607  initGEOS(lwpgnotice, lwgeom_geos_error);
2608 
2609  g1 = (GEOSGeometry *)POSTGIS2GEOS(geom1 );
2610  if (!g1)
2611  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
2612  g2 = (GEOSGeometry *)POSTGIS2GEOS(geom2 );
2613  if (!g2)
2614  {
2615  GEOSGeom_destroy(g1);
2617  "Second argument geometry could not be converted to GEOS");
2618  }
2619 
2620  POSTGIS_DEBUG(3, "constructed geometries ");
2621 
2622  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g1));
2623  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g2));
2624 
2625  relate_str = GEOSRelateBoundaryNodeRule(g1, g2, bnr);
2626 
2627  GEOSGeom_destroy(g1);
2628  GEOSGeom_destroy(g2);
2629 
2630  if (!relate_str) HANDLE_GEOS_ERROR("GEOSRelate");
2631 
2632  result = cstring2text(relate_str);
2633  GEOSFree(relate_str);
2634 
2635  PG_FREE_IF_COPY(geom1, 0);
2636  PG_FREE_IF_COPY(geom2, 1);
2637 
2638  PG_RETURN_TEXT_P(result);
2639 }
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:338
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: