PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ gidx_union_edge()

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

Definition at line 313 of file gserialized_gist_nd.c.

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

Referenced by gserialized_gist_penalty().

314 {
315  float result;
316  int i;
317  int ndims_a, ndims_b;
318 
319  POSTGIS_DEBUG(5,"entered function");
320 
321  if ( a == NULL && b == NULL )
322  {
323  elog(ERROR, "gidx_union_edge received two null arguments");
324  return 0.0;
325  }
326 
327  if ( a == NULL || gidx_is_unknown(a) )
328  return gidx_volume(b);
329 
330  if ( b == NULL || gidx_is_unknown(b) )
331  return gidx_volume(a);
332 
333  if ( gidx_is_unknown(a) && gidx_is_unknown(b) )
334  {
335  return 0.0;
336  }
337 
338  /* Ensure 'a' has the most dimensions. */
340 
341  ndims_a = GIDX_NDIMS(a);
342  ndims_b = GIDX_NDIMS(b);
343 
344  /* Initialize with maximal length of first dimension. */
345  result = Max(GIDX_GET_MAX(a,0),GIDX_GET_MAX(b,0)) - Min(GIDX_GET_MIN(a,0),GIDX_GET_MIN(b,0));
346 
347  /* Add maximal length of remaining dimensions. */
348  for ( i = 1; i < ndims_b; i++ )
349  {
350  result += (Max(GIDX_GET_MAX(a,i),GIDX_GET_MAX(b,i)) - Min(GIDX_GET_MIN(a,i),GIDX_GET_MIN(b,i)));
351  }
352 
353  /* Add in dimensions of higher dimensional box. */
354  for ( i = ndims_b; i < ndims_a; i++ )
355  {
356  result += (GIDX_GET_MAX(a,i) - GIDX_GET_MIN(a,i));
357  }
358 
359  POSTGIS_DEBUGF(5, "edge( %s union %s ) = %.12g", gidx_to_string(a), gidx_to_string(b), result);
360 
361  return result;
362 }
static bool gidx_is_unknown(const GIDX *a)
static float gidx_volume(GIDX *a)
static void gidx_dimensionality_check(GIDX **a, GIDX **b)
Here is the call graph for this function:
Here is the caller graph for this function: