PostGIS  2.3.7dev-r@@SVN_REVISION@@
static float gidx_union_volume ( GIDX *  a,
GIDX *  b 
)
static

Definition at line 247 of file gserialized_gist_nd.c.

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

Referenced by gserialized_gist_penalty().

248 {
249  float result;
250  int i;
251  int ndims_a, ndims_b;
252 
253  POSTGIS_DEBUG(5,"entered function");
254 
255  if ( a == NULL && b == NULL )
256  {
257  elog(ERROR, "gidx_union_volume received two null arguments");
258  return 0.0;
259  }
260 
261  if ( a == NULL || gidx_is_unknown(a) )
262  return gidx_volume(b);
263 
264  if ( b == NULL || gidx_is_unknown(b) )
265  return gidx_volume(a);
266 
267  if ( gidx_is_unknown(a) && gidx_is_unknown(b) )
268  {
269  return 0.0;
270  }
271 
272  /* Ensure 'a' has the most dimensions. */
274 
275  ndims_a = GIDX_NDIMS(a);
276  ndims_b = GIDX_NDIMS(b);
277 
278  /* Initialize with maximal length of first dimension. */
279  result = Max(GIDX_GET_MAX(a,0),GIDX_GET_MAX(b,0)) - Min(GIDX_GET_MIN(a,0),GIDX_GET_MIN(b,0));
280 
281  /* Multiply by maximal length of remaining dimensions. */
282  for ( i = 1; i < ndims_b; i++ )
283  {
284  result *= (Max(GIDX_GET_MAX(a,i),GIDX_GET_MAX(b,i)) - Min(GIDX_GET_MIN(a,i),GIDX_GET_MIN(b,i)));
285  }
286 
287  /* Add in dimensions of higher dimensional box. */
288  for ( i = ndims_b; i < ndims_a; i++ )
289  {
290  result *= (GIDX_GET_MAX(a,i) - GIDX_GET_MIN(a,i));
291  }
292 
293  POSTGIS_DEBUGF(5, "volume( %s union %s ) = %.12g", gidx_to_string(a), gidx_to_string(b), result);
294 
295  return result;
296 }
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: