PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ gidx_contains()

bool gidx_contains ( GIDX *  a,
GIDX *  b 
)

Definition at line 384 of file gserialized_gist_nd.c.

References FALSE, gidx_is_unknown(), and TRUE.

Referenced by gidx_brin_inclusion_add_value(), gserialized_contains(), gserialized_gist_consistent_internal(), gserialized_gist_consistent_leaf(), and gserialized_within().

385 {
386  int i, dims_a, dims_b;
387 
388  POSTGIS_DEBUG(5, "entered function");
389 
390  if ( (a == NULL) || (b == NULL) ) return FALSE;
391 
392  if ( gidx_is_unknown(a) || gidx_is_unknown(b) )
393  return FALSE;
394 
395  dims_a = GIDX_NDIMS(a);
396  dims_b = GIDX_NDIMS(b);
397 
398  if ( dims_a < dims_b )
399  {
400  /*
401  ** If (b) is of higher dimensionality than (a) it can only be contained
402  ** if those higher dimensions are zeroes.
403  */
404  for (i = dims_a; i < dims_b; i++)
405  {
406  if ( GIDX_GET_MIN(b,i) != 0 )
407  return FALSE;
408  if ( GIDX_GET_MAX(b,i) != 0 )
409  return FALSE;
410  }
411  }
412 
413  /* Excess dimensions of (a), don't matter, it just has to contain (b) in (b)'s dimensions */
414  for (i = 0; i < Min(dims_a, dims_b); i++)
415  {
416  if ( GIDX_GET_MIN(a,i) > GIDX_GET_MIN(b,i) )
417  return FALSE;
418  if ( GIDX_GET_MAX(a,i) < GIDX_GET_MAX(b,i) )
419  return FALSE;
420  }
421 
422  return TRUE;
423 }
static bool gidx_is_unknown(const GIDX *a)
#define FALSE
Definition: dbfopen.c:168
#define TRUE
Definition: dbfopen.c:169
Here is the call graph for this function:
Here is the caller graph for this function: