PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ relate_pattern()

Datum relate_pattern ( PG_FUNCTION_ARGS  )

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

2601 {
2602  GSERIALIZED *geom1;
2603  GSERIALIZED *geom2;
2604  char *patt;
2605  char result;
2606  GEOSGeometry *g1, *g2;
2607  size_t i;
2608 
2609  geom1 = PG_GETARG_GSERIALIZED_P(0);
2610  geom2 = PG_GETARG_GSERIALIZED_P(1);
2611  gserialized_error_if_srid_mismatch(geom1, geom2, __func__);
2612 
2613  /* TODO handle empty */
2614 
2615  initGEOS(lwpgnotice, lwgeom_geos_error);
2616 
2617  g1 = POSTGIS2GEOS(geom1);
2618  if (!g1)
2619  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
2620  g2 = POSTGIS2GEOS(geom2);
2621  if (!g2)
2622  {
2623  GEOSGeom_destroy(g1);
2624  HANDLE_GEOS_ERROR("Second argument geometry could not be converted to GEOS");
2625  }
2626 
2627  patt = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(2)));
2628 
2629  /*
2630  ** Need to make sure 't' and 'f' are upper-case before handing to GEOS
2631  */
2632  for ( i = 0; i < strlen(patt); i++ )
2633  {
2634  if ( patt[i] == 't' ) patt[i] = 'T';
2635  if ( patt[i] == 'f' ) patt[i] = 'F';
2636  }
2637 
2638  result = GEOSRelatePattern(g1,g2,patt);
2639  GEOSGeom_destroy(g1);
2640  GEOSGeom_destroy(g2);
2641  pfree(patt);
2642 
2643  if (result == 2) HANDLE_GEOS_ERROR("GEOSRelatePattern");
2644 
2645  PG_FREE_IF_COPY(geom1, 0);
2646  PG_FREE_IF_COPY(geom2, 1);
2647 
2648  PG_RETURN_BOOL(result);
2649 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
Definition: gserialized.c:403
void lwgeom_geos_error(const char *fmt,...)
GEOSGeometry * POSTGIS2GEOS(const GSERIALIZED *pglwgeom)
#define HANDLE_GEOS_ERROR(label)

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

Here is the call graph for this function: