PostGIS  2.3.6-r@@SVN_REVISION@@
Datum relate_full ( PG_FUNCTION_ARGS  )

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

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

2638 {
2639  GSERIALIZED *geom1;
2640  GSERIALIZED *geom2;
2641  GEOSGeometry *g1, *g2;
2642  char *relate_str;
2643  text *result;
2644  int bnr = GEOSRELATE_BNR_OGC;
2645 
2646  POSTGIS_DEBUG(2, "in relate_full()");
2647 
2648  /* TODO handle empty */
2649 
2650  geom1 = PG_GETARG_GSERIALIZED_P(0);
2651  geom2 = PG_GETARG_GSERIALIZED_P(1);
2652 
2653  if ( PG_NARGS() > 2 )
2654  {
2655  bnr = PG_GETARG_INT32(2);
2656  }
2657 
2658  errorIfGeometryCollection(geom1,geom2);
2660 
2661  initGEOS(lwpgnotice, lwgeom_geos_error);
2662 
2663  g1 = (GEOSGeometry *)POSTGIS2GEOS(geom1 );
2664  if ( 0 == g1 ) /* exception thrown at construction */
2665  {
2666  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
2667  PG_RETURN_NULL();
2668  }
2669  g2 = (GEOSGeometry *)POSTGIS2GEOS(geom2 );
2670  if ( 0 == g2 ) /* exception thrown at construction */
2671  {
2672  HANDLE_GEOS_ERROR("Second argument geometry could not be converted to GEOS");
2673  GEOSGeom_destroy(g1);
2674  PG_RETURN_NULL();
2675  }
2676 
2677  POSTGIS_DEBUG(3, "constructed geometries ");
2678 
2679  if ((g1==NULL) || (g2 == NULL))
2680  elog(NOTICE,"g1 or g2 are null");
2681 
2682  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g1));
2683  POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g2));
2684 
2685  relate_str = GEOSRelateBoundaryNodeRule(g1, g2, bnr);
2686 
2687  GEOSGeom_destroy(g1);
2688  GEOSGeom_destroy(g2);
2689 
2690  if (relate_str == NULL)
2691  {
2692  HANDLE_GEOS_ERROR("GEOSRelate");
2693  PG_RETURN_NULL(); /* never get here */
2694  }
2695 
2696  result = cstring2text(relate_str);
2697  GEOSFree(relate_str);
2698 
2699  PG_FREE_IF_COPY(geom1, 0);
2700  PG_FREE_IF_COPY(geom2, 1);
2701 
2702  PG_RETURN_TEXT_P(result);
2703 }
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:369
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:83
void errorIfGeometryCollection(GSERIALIZED *g1, GSERIALIZED *g2)
Throws an ereport ERROR if either geometry is a COLLECTIONTYPE.

Here is the call graph for this function: