PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ relate_full()

Datum relate_full ( PG_FUNCTION_ARGS  )

Definition at line 2445 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().

2446 {
2447  GSERIALIZED *geom1;
2448  GSERIALIZED *geom2;
2449  GEOSGeometry *g1, *g2;
2450  char *relate_str;
2451  text *result;
2452  int bnr = GEOSRELATE_BNR_OGC;
2453 
2454  POSTGIS_DEBUG(2, "in relate_full()");
2455 
2456  /* TODO handle empty */
2457 
2458  geom1 = PG_GETARG_GSERIALIZED_P(0);
2459  geom2 = PG_GETARG_GSERIALIZED_P(1);
2460 
2461  if ( PG_NARGS() > 2 )
2462  {
2463  bnr = PG_GETARG_INT32(2);
2464  }
2465 
2466  errorIfGeometryCollection(geom1,geom2);
2468 
2469  initGEOS(lwpgnotice, lwgeom_geos_error);
2470 
2471  g1 = POSTGIS2GEOS(geom1 );
2472  if (!g1)
2473  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
2474  g2 = POSTGIS2GEOS(geom2 );
2475  if (!g2)
2476  {
2477  GEOSGeom_destroy(g1);
2478  HANDLE_GEOS_ERROR("Second argument geometry could not be converted to GEOS");
2479  }
2480 
2481  POSTGIS_DEBUG(3, "constructed geometries ");
2482 
2483  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g1));
2484  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g2));
2485 
2486  relate_str = GEOSRelateBoundaryNodeRule(g1, g2, bnr);
2487 
2488  GEOSGeom_destroy(g1);
2489  GEOSGeom_destroy(g2);
2490 
2491  if (!relate_str) HANDLE_GEOS_ERROR("GEOSRelate");
2492 
2493  result = cstring_to_text(relate_str);
2494  GEOSFree(relate_str);
2495 
2496  PG_FREE_IF_COPY(geom1, 0);
2497  PG_FREE_IF_COPY(geom2, 1);
2498 
2499  PG_RETURN_TEXT_P(result);
2500 }
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:
Here is the caller graph for this function: