PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ gidx_union_volume()

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

Definition at line 217 of file gserialized_gist_nd.c.

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

Referenced by gserialized_gist_penalty().

218 {
219  float result;
220  int i;
221  int ndims_a, ndims_b;
222 
223  POSTGIS_DEBUG(5,"entered function");
224 
225  if ( a == NULL && b == NULL )
226  {
227  elog(ERROR, "gidx_union_volume received two null arguments");
228  return 0.0;
229  }
230 
231  if ( a == NULL || gidx_is_unknown(a) )
232  return gidx_volume(b);
233 
234  if ( b == NULL || gidx_is_unknown(b) )
235  return gidx_volume(a);
236 
237  if ( gidx_is_unknown(a) && gidx_is_unknown(b) )
238  {
239  return 0.0;
240  }
241 
242  /* Ensure 'a' has the most dimensions. */
244 
245  ndims_a = GIDX_NDIMS(a);
246  ndims_b = GIDX_NDIMS(b);
247 
248  /* Initialize with maximal length of first dimension. */
249  result = Max(GIDX_GET_MAX(a,0),GIDX_GET_MAX(b,0)) - Min(GIDX_GET_MIN(a,0),GIDX_GET_MIN(b,0));
250 
251  /* Multiply by maximal length of remaining dimensions. */
252  for ( i = 1; i < ndims_b; i++ )
253  {
254  result *= (Max(GIDX_GET_MAX(a,i),GIDX_GET_MAX(b,i)) - Min(GIDX_GET_MIN(a,i),GIDX_GET_MIN(b,i)));
255  }
256 
257  /* Add in dimensions of higher dimensional box. */
258  for ( i = ndims_b; i < ndims_a; i++ )
259  {
260  result *= (GIDX_GET_MAX(a,i) - GIDX_GET_MIN(a,i));
261  }
262 
263  POSTGIS_DEBUGF(5, "volume( %s union %s ) = %.12g", gidx_to_string(a), gidx_to_string(b), result);
264 
265  return result;
266 }
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: