PostGIS  2.3.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 541 of file gserialized_gist_nd.c.

Referenced by gserialized_distance_nd(), and gserialized_gist_distance().

542 {
543  int ndims, i;
544  double sum = 0;
545 
546  /* Base computation on least available dimensions */
547  ndims = Min(GIDX_NDIMS(b), GIDX_NDIMS(a));
548  for ( i = 0; i < ndims; ++i )
549  {
550  double ca, cb, d;
551  double amin = GIDX_GET_MIN(a,i);
552  double amax = GIDX_GET_MAX(a,i);
553  double bmin = GIDX_GET_MIN(b,i);
554  double bmax = GIDX_GET_MAX(b,i);
555  ca = amin + ( ( amax - amin ) / 2.0 );
556  cb = bmin + ( ( bmax - bmin ) / 2.0 );
557  d = ca - cb;
558  if ( ! isfinite(d) )
559  {
560  /* Can happen if a dimension was padded with FLT_MAX,
561  * effectively meaning "infinite range". In that case
562  * we take that dimension as adding 0 to the total
563  * distance.
564  */
565  continue;
566  }
567  sum += d * d;
568 /*
569  POSTGIS_DEBUGF(3, " centroid of A for dimension %d is %g", i, ca);
570  POSTGIS_DEBUGF(3, " centroid of B for dimension %d is %g", i, cb);
571  POSTGIS_DEBUGF(3, " distance on dimension %d is %g, squared as %g, grows sum to %g", i, d, d*d, sum);
572 */
573  }
574  return sqrt(sum);
575 }

Here is the caller graph for this function: