PostGIS  2.2.7dev-r@@SVN_REVISION@@
static float gidx_inter_volume ( GIDX *  a,
GIDX *  b 
)
static

Definition at line 269 of file gserialized_gist_nd.c.

References gidx_dimensionality_check(), and gidx_is_unknown().

Referenced by gserialized_gist_picksplit_constructsplit().

270 {
271  int i;
272  float result;
273 
274  POSTGIS_DEBUG(5,"entered function");
275 
276  if ( a == NULL || b == NULL )
277  {
278  elog(ERROR, "gidx_inter_volume received a null argument");
279  return 0.0;
280  }
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  /* Initialize with minimal length of first dimension. */
291  result = Min(GIDX_GET_MAX(a,0),GIDX_GET_MAX(b,0)) - Max(GIDX_GET_MIN(a,0),GIDX_GET_MIN(b,0));
292 
293  /* If they are disjoint (max < min) then return zero. */
294  if ( result < 0.0 ) return 0.0;
295 
296  /* Continue for remaining dimensions. */
297  for ( i = 1; i < GIDX_NDIMS(b); i++ )
298  {
299  float width = Min(GIDX_GET_MAX(a,i),GIDX_GET_MAX(b,i)) - Max(GIDX_GET_MIN(a,i),GIDX_GET_MIN(b,i));
300  if ( width < 0.0 ) return 0.0;
301  /* Multiply by minimal length of remaining dimensions. */
302  result *= width;
303  }
304  POSTGIS_DEBUGF(5, "volume( %s intersection %s ) = %.12g", gidx_to_string(a), gidx_to_string(b), result);
305  return result;
306 }
static bool gidx_is_unknown(const 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: