PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ relate_full()

Datum relate_full ( PG_FUNCTION_ARGS  )

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

2709 {
2710  GSERIALIZED *geom1;
2711  GSERIALIZED *geom2;
2712  GEOSGeometry *g1, *g2;
2713  char *relate_str;
2714  text *result;
2715  int bnr = GEOSRELATE_BNR_OGC;
2716 
2717  POSTGIS_DEBUG(2, "in relate_full()");
2718 
2719  /* TODO handle empty */
2720 
2721  geom1 = PG_GETARG_GSERIALIZED_P(0);
2722  geom2 = PG_GETARG_GSERIALIZED_P(1);
2723 
2724  if ( PG_NARGS() > 2 )
2725  {
2726  bnr = PG_GETARG_INT32(2);
2727  }
2728 
2729  errorIfGeometryCollection(geom1,geom2);
2731 
2732  initGEOS(lwpgnotice, lwgeom_geos_error);
2733 
2734  g1 = (GEOSGeometry *)POSTGIS2GEOS(geom1 );
2735  if ( 0 == g1 ) /* exception thrown at construction */
2736  {
2737  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
2738  PG_RETURN_NULL();
2739  }
2740  g2 = (GEOSGeometry *)POSTGIS2GEOS(geom2 );
2741  if ( 0 == g2 ) /* exception thrown at construction */
2742  {
2743  HANDLE_GEOS_ERROR("Second argument geometry could not be converted to GEOS");
2744  GEOSGeom_destroy(g1);
2745  PG_RETURN_NULL();
2746  }
2747 
2748  POSTGIS_DEBUG(3, "constructed geometries ");
2749 
2750  if ((g1==NULL) || (g2 == NULL))
2751  elog(NOTICE,"g1 or g2 are null");
2752 
2753  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g1));
2754  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g2));
2755 
2756  relate_str = GEOSRelateBoundaryNodeRule(g1, g2, bnr);
2757 
2758  GEOSGeom_destroy(g1);
2759  GEOSGeom_destroy(g2);
2760 
2761  if (relate_str == NULL)
2762  {
2763  HANDLE_GEOS_ERROR("GEOSRelate");
2764  PG_RETURN_NULL(); /* never get here */
2765  }
2766 
2767  result = cstring2text(relate_str);
2768  GEOSFree(relate_str);
2769 
2770  PG_FREE_IF_COPY(geom1, 0);
2771  PG_FREE_IF_COPY(geom2, 1);
2772 
2773  PG_RETURN_TEXT_P(result);
2774 }
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:371
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: