PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ relate_full()

Datum relate_full ( PG_FUNCTION_ARGS  )

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

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