PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ gidx_union_volume()

static float gidx_union_volume ( GIDX *  a,
GIDX *  b 
)
static

Definition at line 262 of file gserialized_gist_nd.c.

263 {
264  float result;
265  int i;
266  int ndims_a, ndims_b;
267 
268  POSTGIS_DEBUG(5,"entered function");
269 
270  if ( a == NULL && b == NULL )
271  {
272  elog(ERROR, "gidx_union_volume received two null arguments");
273  return 0.0;
274  }
275 
276  if ( a == NULL || gidx_is_unknown(a) )
277  return gidx_volume(b);
278 
279  if ( b == NULL || gidx_is_unknown(b) )
280  return gidx_volume(a);
281 
282  if ( gidx_is_unknown(a) && gidx_is_unknown(b) )
283  {
284  return 0.0;
285  }
286 
287  /* Ensure 'a' has the most dimensions. */
289 
290  ndims_a = GIDX_NDIMS(a);
291  ndims_b = GIDX_NDIMS(b);
292 
293  /* Initialize with maximal length of first dimension. */
294  result = Max(GIDX_GET_MAX(a,0),GIDX_GET_MAX(b,0)) - Min(GIDX_GET_MIN(a,0),GIDX_GET_MIN(b,0));
295 
296  /* Multiply by maximal length of remaining dimensions. */
297  for ( i = 1; i < ndims_b; i++ )
298  {
299  result *= (Max(GIDX_GET_MAX(a,i),GIDX_GET_MAX(b,i)) - Min(GIDX_GET_MIN(a,i),GIDX_GET_MIN(b,i)));
300  }
301 
302  /* Add in dimensions of higher dimensional box. */
303  for ( i = ndims_b; i < ndims_a; i++ )
304  {
305  result *= (GIDX_GET_MAX(a,i) - GIDX_GET_MIN(a,i));
306  }
307 
308  POSTGIS_DEBUGF(5, "volume( %s union %s ) = %.12g", gidx_to_string(a), gidx_to_string(b), result);
309 
310  return result;
311 }
bool gidx_is_unknown(const GIDX *a)
static float gidx_volume(GIDX *a)
static void gidx_dimensionality_check(GIDX **a, GIDX **b)

References gidx_dimensionality_check(), gidx_is_unknown(), and gidx_volume().

Referenced by gserialized_gist_penalty().

Here is the call graph for this function:
Here is the caller graph for this function: