PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ gidx_union_volume()

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

Definition at line 261 of file gserialized_gist_nd.c.

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

Referenced by gserialized_gist_penalty().

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