PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ relate_pattern()

Datum relate_pattern ( PG_FUNCTION_ARGS  )

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

2428 {
2429  GSERIALIZED *geom1;
2430  GSERIALIZED *geom2;
2431  char *patt;
2432  char result;
2433  GEOSGeometry *g1, *g2;
2434  size_t i;
2435 
2436  geom1 = PG_GETARG_GSERIALIZED_P(0);
2437  geom2 = PG_GETARG_GSERIALIZED_P(1);
2438  gserialized_error_if_srid_mismatch(geom1, geom2, __func__);
2439 
2440  /* TODO handle empty */
2441 
2442  initGEOS(lwpgnotice, lwgeom_geos_error);
2443 
2444  g1 = POSTGIS2GEOS(geom1);
2445  if (!g1)
2446  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
2447  g2 = POSTGIS2GEOS(geom2);
2448  if (!g2)
2449  {
2450  GEOSGeom_destroy(g1);
2451  HANDLE_GEOS_ERROR("Second argument geometry could not be converted to GEOS");
2452  }
2453 
2454  patt = DatumGetCString(DirectFunctionCall1(textout,
2455  PointerGetDatum(PG_GETARG_DATUM(2))));
2456 
2457  /*
2458  ** Need to make sure 't' and 'f' are upper-case before handing to GEOS
2459  */
2460  for ( i = 0; i < strlen(patt); i++ )
2461  {
2462  if ( patt[i] == 't' ) patt[i] = 'T';
2463  if ( patt[i] == 'f' ) patt[i] = 'F';
2464  }
2465 
2466  result = GEOSRelatePattern(g1,g2,patt);
2467  GEOSGeom_destroy(g1);
2468  GEOSGeom_destroy(g2);
2469  pfree(patt);
2470 
2471  if (result == 2) HANDLE_GEOS_ERROR("GEOSRelatePattern");
2472 
2473  PG_FREE_IF_COPY(geom1, 0);
2474  PG_FREE_IF_COPY(geom2, 1);
2475 
2476  PG_RETURN_BOOL(result);
2477 }
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
Definition: gserialized.c:404
void lwgeom_geos_error(const char *fmt,...)
#define HANDLE_GEOS_ERROR(label)
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)

References gserialized_error_if_srid_mismatch(), HANDLE_GEOS_ERROR, lwgeom_geos_error(), and POSTGIS2GEOS().

Here is the call graph for this function: