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

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

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

2526 {
2527  GSERIALIZED *geom1;
2528  GSERIALIZED *geom2;
2529  char *patt;
2530  bool result;
2531  GEOSGeometry *g1, *g2;
2532  size_t i;
2533 
2534  geom1 = PG_GETARG_GSERIALIZED_P(0);
2535  geom2 = PG_GETARG_GSERIALIZED_P(1);
2536 
2537  /* TODO handle empty */
2538 
2539  errorIfGeometryCollection(geom1,geom2);
2541 
2542  initGEOS(lwpgnotice, lwgeom_geos_error);
2543 
2544  g1 = (GEOSGeometry *)POSTGIS2GEOS(geom1);
2545  if (!g1)
2546  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
2547  g2 = (GEOSGeometry *)POSTGIS2GEOS(geom2);
2548  if (!g2)
2549  {
2550  GEOSGeom_destroy(g1);
2552  "Second argument geometry could not be converted to GEOS");
2553  }
2554 
2555  patt = DatumGetCString(DirectFunctionCall1(textout,
2556  PointerGetDatum(PG_GETARG_DATUM(2))));
2557 
2558  /*
2559  ** Need to make sure 't' and 'f' are upper-case before handing to GEOS
2560  */
2561  for ( i = 0; i < strlen(patt); i++ )
2562  {
2563  if ( patt[i] == 't' ) patt[i] = 'T';
2564  if ( patt[i] == 'f' ) patt[i] = 'F';
2565  }
2566 
2567  result = GEOSRelatePattern(g1,g2,patt);
2568  GEOSGeom_destroy(g1);
2569  GEOSGeom_destroy(g2);
2570  pfree(patt);
2571 
2572  if (result == 2) HANDLE_GEOS_ERROR("GEOSRelatePattern");
2573 
2574  PG_FREE_IF_COPY(geom1, 0);
2575  PG_FREE_IF_COPY(geom2, 1);
2576 
2577  PG_RETURN_BOOL(result);
2578 }
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: