PostGIS  2.2.7dev-r@@SVN_REVISION@@
static double gidx_distance_leaf_centroid ( const GIDX *  a,
const GIDX *  b 
)
static

Calculate the centroid->centroid distance between the boxes.

Definition at line 468 of file gserialized_gist_nd.c.

Referenced by gserialized_distance_nd(), and gserialized_gist_distance().

469 {
470  int ndims, i;
471  double sum = 0;
472 
473  /* Base computation on least available dimensions */
474  ndims = Min(GIDX_NDIMS(b), GIDX_NDIMS(a));
475  for ( i = 0; i < ndims; ++i )
476  {
477  double ca, cb, d;
478  double amin = GIDX_GET_MIN(a,i);
479  double amax = GIDX_GET_MAX(a,i);
480  double bmin = GIDX_GET_MIN(b,i);
481  double bmax = GIDX_GET_MAX(b,i);
482  ca = amin + ( ( amax - amin ) / 2.0 );
483  cb = bmin + ( ( bmax - bmin ) / 2.0 );
484  d = ca - cb;
485  if ( ! isfinite(d) )
486  {
487  /* Can happen if a dimension was padded with FLT_MAX,
488  * effectively meaning "infinite range". In that case
489  * we take that dimension as adding 0 to the total
490  * distance.
491  */
492  continue;
493  }
494  sum += d * d;
495 /*
496  POSTGIS_DEBUGF(3, " centroid of A for dimension %d is %g", i, ca);
497  POSTGIS_DEBUGF(3, " centroid of B for dimension %d is %g", i, cb);
498  POSTGIS_DEBUGF(3, " distance on dimension %d is %g, squared as %g, grows sum to %g", i, d, d*d, sum);
499 */
500  }
501  return sqrt(sum);
502 }

Here is the caller graph for this function: