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

Definition at line 212 of file gserialized_gist_nd.c.

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

Referenced by gserialized_gist_penalty().

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